1 | <?php |
||||
2 | /** |
||||
3 | * Copyright (c) 2018 - present |
||||
4 | * Google Maps PHP - GoogleMapsClient.php |
||||
5 | * author: Roberto Belotti - [email protected] |
||||
6 | * web : robertobelotti.com, github.com/biscolab |
||||
7 | * Initial version created on: 5/9/2018 |
||||
8 | * MIT license: https://github.com/biscolab/google-maps-php/blob/master/LICENSE |
||||
9 | */ |
||||
10 | |||||
11 | namespace Biscolab\GoogleMaps\Http; |
||||
12 | |||||
13 | use Biscolab\GoogleMaps\Values\GoogleMapsRequestMethodValues; |
||||
14 | use GuzzleHttp\Client; |
||||
15 | use GuzzleHttp\Psr7\Response; |
||||
16 | |||||
17 | class GoogleMapsClient |
||||
18 | { |
||||
19 | |||||
20 | /** |
||||
21 | * @var Client |
||||
22 | */ |
||||
23 | protected $client = null; |
||||
24 | |||||
25 | /** |
||||
26 | * GeocoderClient constructor. |
||||
27 | */ |
||||
28 | 35 | public function __construct() |
|||
29 | { |
||||
30 | |||||
31 | 35 | $this->setClient(new Client()); |
|||
32 | 35 | } |
|||
33 | |||||
34 | /** |
||||
35 | * @param null $client |
||||
0 ignored issues
–
show
Documentation
Bug
introduced
by
![]() |
|||||
36 | * |
||||
37 | * @return GoogleMapsClient |
||||
38 | */ |
||||
39 | 35 | public function setClient($client) |
|||
40 | { |
||||
41 | |||||
42 | 35 | $this->client = $client; |
|||
43 | |||||
44 | 35 | return $this; |
|||
45 | } |
||||
46 | |||||
47 | /** |
||||
48 | * @param string $url |
||||
49 | * @param null|string $query |
||||
50 | * |
||||
51 | * @return \Biscolab\GoogleMaps\Http\GoogleMapsResponse |
||||
52 | */ |
||||
53 | public function get(string $url, ?string $query = null): GoogleMapsResponse |
||||
54 | { |
||||
55 | |||||
56 | $client_params = $query ? [ |
||||
57 | 'query' => $query |
||||
58 | ] : null; |
||||
59 | |||||
60 | /** @var Response $res */ |
||||
61 | $res = $this->client->request(GoogleMapsRequestMethodValues::GET, $url, $client_params); |
||||
0 ignored issues
–
show
It seems like
$client_params can also be of type null ; however, parameter $options of GuzzleHttp\Client::request() does only seem to accept array , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
62 | |||||
63 | return new GoogleMapsResponse($res); |
||||
64 | } |
||||
65 | } |