Conditions | 3 |
Paths | 3 |
Total Lines | 21 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
17 | public function getMock(array $responseCollection) |
||
18 | { |
||
19 | $version5ResponseCollection = []; |
||
20 | $client = GuzzleFactory::createClient(''); |
||
21 | |||
22 | foreach ($responseCollection as $response) { |
||
23 | if ($response instanceof Psr7Response) { |
||
24 | $version5ResponseCollection[] = new Response( |
||
25 | $response->getStatusCode(), |
||
26 | $response->getHeaders(), |
||
27 | Stream::factory($response->getBody()->getContents()) |
||
28 | ); |
||
29 | } else { |
||
30 | $version5ResponseCollection[] = new Response(); |
||
31 | } |
||
32 | } |
||
33 | $mock = new Mock($version5ResponseCollection); |
||
34 | $client->getEmitter()->attach($mock); |
||
|
|||
35 | |||
36 | return $client; |
||
37 | } |
||
38 | } |
||
39 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: