Skip to content

Commit

Permalink
Work around where empty lists are missing from responses (#1621)
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamCampbell authored Dec 8, 2023
1 parent c2bc603 commit d3d09bc
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Exception/ValidationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected function populateResult(ResponseInterface $response): void
{
$data = $response->toArray(false);

$this->fieldList = $this->populateResultValidationExceptionFieldList($data['fieldList']);
$this->fieldList = $this->populateResultValidationExceptionFieldList($data['fieldList'] ?? []);
$this->reason = (string) $data['reason'];
}

Expand Down
8 changes: 4 additions & 4 deletions src/Result/CalculateRouteMatrixResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected function populateResult(Response $response): void
{
$data = $response->toArray();

$this->routeMatrix = $this->populateResultRouteMatrix($data['RouteMatrix']);
$this->routeMatrix = $this->populateResultRouteMatrix($data['RouteMatrix'] ?? []);
$this->snappedDeparturePositions = empty($data['SnappedDeparturePositions']) ? [] : $this->populateResultCalculateRouteMatrixResponseSnappedDeparturePositionsList($data['SnappedDeparturePositions']);
$this->snappedDestinationPositions = empty($data['SnappedDestinationPositions']) ? [] : $this->populateResultCalculateRouteMatrixResponseSnappedDestinationPositionsList($data['SnappedDestinationPositions']);
$this->summary = $this->populateResultCalculateRouteMatrixSummary($data['Summary']);
Expand All @@ -100,7 +100,7 @@ private function populateResultCalculateRouteMatrixResponseSnappedDeparturePosit
{
$items = [];
foreach ($json as $item) {
$items[] = $this->populateResultPosition($item);
$items[] = $this->populateResultPosition($item ?? []);
}

return $items;
Expand All @@ -113,7 +113,7 @@ private function populateResultCalculateRouteMatrixResponseSnappedDestinationPos
{
$items = [];
foreach ($json as $item) {
$items[] = $this->populateResultPosition($item);
$items[] = $this->populateResultPosition($item ?? []);
}

return $items;
Expand Down Expand Up @@ -152,7 +152,7 @@ private function populateResultRouteMatrix(array $json): array
{
$items = [];
foreach ($json as $item) {
$items[] = $this->populateResultRouteMatrixRow($item);
$items[] = $this->populateResultRouteMatrixRow($item ?? []);
}

return $items;
Expand Down
2 changes: 1 addition & 1 deletion src/Result/CalculateRouteResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ protected function populateResult(Response $response): void
{
$data = $response->toArray();

$this->legs = $this->populateResultLegList($data['Legs']);
$this->legs = $this->populateResultLegList($data['Legs'] ?? []);
$this->summary = $this->populateResultCalculateRouteSummary($data['Summary']);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Result/SearchPlaceIndexForPositionResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected function populateResult(Response $response): void
{
$data = $response->toArray();

$this->results = $this->populateResultSearchForPositionResultList($data['Results']);
$this->results = $this->populateResultSearchForPositionResultList($data['Results'] ?? []);
$this->summary = $this->populateResultSearchPlaceIndexForPositionSummary($data['Summary']);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Result/SearchPlaceIndexForTextResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected function populateResult(Response $response): void
{
$data = $response->toArray();

$this->results = $this->populateResultSearchForTextResultList($data['Results']);
$this->results = $this->populateResultSearchForTextResultList($data['Results'] ?? []);
$this->summary = $this->populateResultSearchPlaceIndexForTextSummary($data['Summary']);
}

Expand Down

0 comments on commit d3d09bc

Please sign in to comment.