diff --git a/src/Models/SwaggerModel.php b/src/Models/SwaggerModel.php index 3fdb4ad..64087ad 100644 --- a/src/Models/SwaggerModel.php +++ b/src/Models/SwaggerModel.php @@ -9,9 +9,6 @@ class SwaggerModel implements JsonSerializable { private $_is_error = false; - /** - * @return array - */ public function toArray(): array{ $this->preOutput(); @@ -24,9 +21,7 @@ public function toArray(): array{ $data[$key] = $val; } - $data = $this->toArrayData($data); - - return $data; + return $this->toArrayData($data); } /** @@ -35,18 +30,10 @@ public function toArray(): array{ protected function preOutput(): void{ } - /** - * @return array - */ - public function jsonSerialize(){ + public function jsonSerialize(): array{ return $this->toArray(); } - /** - * @param array $data - * - * @return array - */ private function toArrayData(array $data): array{ foreach ($data as &$val){ @@ -70,9 +57,6 @@ private function toArrayData(array $data): array{ return $data; } - /** - * @return bool - */ public function isError(): bool{ return $this->_is_error; } diff --git a/src/Requests/SwaggerRequest.php b/src/Requests/SwaggerRequest.php index 5c1550b..7a89b06 100644 --- a/src/Requests/SwaggerRequest.php +++ b/src/Requests/SwaggerRequest.php @@ -374,6 +374,9 @@ private function makeUri() :UriInterface{ $uri = static::URI; $query = []; foreach (static::$path_params as $param_name){ + if (!isset($this->{$param_name})){ + continue; + } $query[] = $this->{$param_name}; } if (!empty($query)){ diff --git a/src/SturentsClient.php b/src/SturentsClient.php index 0cdd716..106a304 100644 --- a/src/SturentsClient.php +++ b/src/SturentsClient.php @@ -138,9 +138,9 @@ protected function handleResponse(ResponseInterface $response, array $response_m $json = (string)$response->getBody(); $status = (string)$response->getStatusCode(); - $response_class = $response_models[$status]; + $response_class = $response_models[$status] ?? null; if (is_null($response_class)){ - $response_class = $response_models['default']; + $response_class = $response_models['default'] ?? null; } if (empty($json) && empty($response_class)){