Guzzle6Mock::getMock()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
3
namespace CanalTP\AbstractGuzzle\Mock;
4
5
use CanalTP\AbstractGuzzle\GuzzleFactory;
6
use GuzzleHttp\Handler\MockHandler;
7
use GuzzleHttp\HandlerStack;
8
9
class Guzzle6Mock
10
{
11
    /**
12
     * Guzzle6Mock .
13
     *
14
     * @param array $responseCollection new Response(200, ['X-Foo' => 'Bar']),
15
     * new Response(202, ['Content-Length' => 0]),
16
     * new RequestException("Error Communicating with Server", new Request('GET', 'test'))
17
     * @return \CanalTP\AbstractGuzzle\Guzzle
18
     */
19
    public function getMock(array $responseCollection)
20
    {
21
        $mock = new MockHandler($responseCollection);
22
        $handler = HandlerStack::create($mock);
23
24
        return GuzzleFactory::createClient('', ['handler' => $handler]);
25
    }
26
}
27