Skip to content

Commit

Permalink
Fix deprecated Guzzle functions.
Browse files Browse the repository at this point in the history
* Replace query builder function with method on Query object.
* Added explicit leading '/' on every path due to guzzle deprecatino
  warning.
  • Loading branch information
judgej committed Aug 23, 2021
1 parent ebfe5bd commit 34f7fe2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/Request/Models/Endpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
use Consilience\Starling\Payments\HydratableTrait;
use Consilience\Starling\Payments\ValidationTrait;
use Consilience\Starling\Payments\ModelInterface;
use UnexpectedValueException;

use function GuzzleHttp\Psr7\build_query;
use GuzzleHttp\Psr7\Query;
use GuzzleHttp\Psr7\Uri;

class Endpoint implements ModelInterface
Expand Down Expand Up @@ -98,11 +96,15 @@ public function getUrl($servicePath = '', $query = [])
$replacements['{' . $fieldName . '}'] = $this->getProperty($fieldName);
}

$path = str_replace(
array_keys($replacements),
array_values($replacements),
$template
);
// A URL with an authority must start with a slash.

$path = '/' . ltrim(
str_replace(
array_keys($replacements),
array_values($replacements),
$template
),
'/');

$uri = new Uri();

Expand All @@ -112,7 +114,7 @@ public function getUrl($servicePath = '', $query = [])
->withHost($this->host);

if (! empty($query)) {
$uri = $uri->withQuery(build_query($query));
$uri = $uri->withQuery(Query::build($query));
}

return $uri;
Expand Down
1 change: 1 addition & 0 deletions tests/Response/BusinessInformationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public function testFromPSR7($contentType)
"minorUnits": 12345
}
}';

$businessInformationResponse = new Psr7Response(
200,
[
Expand Down

0 comments on commit 34f7fe2

Please sign in to comment.