Skip to content

Commit

Permalink
Merge pull request #13 from sturents/craig/undefined-fixes
Browse files Browse the repository at this point in the history
Fixes for a couple of undefined key/property issues
  • Loading branch information
M1ke authored Aug 18, 2023
2 parents 237fe74 + 00f7695 commit 61435e4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 20 deletions.
20 changes: 2 additions & 18 deletions src/Models/SwaggerModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ class SwaggerModel implements JsonSerializable {

private $_is_error = false;

/**
* @return array
*/
public function toArray(): array{
$this->preOutput();

Expand All @@ -24,9 +21,7 @@ public function toArray(): array{
$data[$key] = $val;
}

$data = $this->toArrayData($data);

return $data;
return $this->toArrayData($data);
}

/**
Expand All @@ -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){

Expand All @@ -70,9 +57,6 @@ private function toArrayData(array $data): array{
return $data;
}

/**
* @return bool
*/
public function isError(): bool{
return $this->_is_error;
}
Expand Down
3 changes: 3 additions & 0 deletions src/Requests/SwaggerRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)){
Expand Down
4 changes: 2 additions & 2 deletions src/SturentsClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)){
Expand Down

0 comments on commit 61435e4

Please sign in to comment.