1010abstract class AbstractResponseEntity extends Response
1111{
1212
13- /**
14- * @param Response|ResponseInterface $origin
15- */
16- public function __construct ($ origin )
13+ public function __construct (Response |ResponseInterface $ origin )
1714 {
1815 if ($ origin instanceof Response) {
1916 $ origin = $ origin ->getOrigin ();
@@ -22,12 +19,7 @@ public function __construct($origin)
2219 parent ::__construct ($ origin );
2320 }
2421
25- /**
26- * @param string $fieldId
27- * @param int|string|null $default
28- * @return int|string|null
29- */
30- public function get (string $ fieldId , $ default = null )
22+ public function get (string $ fieldId , int |string |null $ default = null ): int |string |null
3123 {
3224 $ value = $ this ->getData ()[$ fieldId ] ?? $ default ;
3325 if ($ value !== null && !is_string ($ value ) && !is_int ($ value )) {
@@ -37,6 +29,21 @@ public function get(string $fieldId, $default = null)
3729 return $ value ;
3830 }
3931
32+ public function getErrorCode (): int
33+ {
34+ return $ this ->getRequiredInteger ('code ' );
35+ }
36+
37+ public function getErrorMessage (): ?string
38+ {
39+ return $ this ->getString ('message ' );
40+ }
41+
42+ public function isOk (): bool
43+ {
44+ return $ this ->getInteger ('code ' , -1 ) === 0 ;
45+ }
46+
4047 /**
4148 * @phpstan-return ($default is null ? (string|null) : string)
4249 */
@@ -91,19 +98,4 @@ protected function getRequiredBool(string $fieldId): bool
9198 return $ value ;
9299 }
93100
94- public function getErrorCode (): int
95- {
96- return $ this ->getRequiredInteger ('code ' );
97- }
98-
99- public function getErrorMessage (): ?string
100- {
101- return $ this ->getString ('message ' );
102- }
103-
104- public function isOk (): bool
105- {
106- return $ this ->getInteger ('code ' , -1 ) === 0 ;
107- }
108-
109101}
0 commit comments