Passed
Branch real-time-api (b64dfc)
by James
03:20
created

MockClient::getClient()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: james
5
 * Date: 25/07/2018
6
 * Time: 13:04
7
 */
8
9
namespace CwsOps\LivePerson\Tests;
10
11
use GuzzleHttp\Client;
12
use GuzzleHttp\Handler\MockHandler;
13
use GuzzleHttp\HandlerStack;
14
use GuzzleHttp\Psr7\Response;
15
16
/**
17
 * Class MockClient
18
 * @package CwsOps\LivePerson\Tests
19
 * @author James Parker <[email protected]>
20
 */
21
class MockClient
22
{
23
    /**
24
     * @param Response[] $queue
25
     *
26
     * @return Client
27
     */
28
    public static function getClient(array $queue)
29
    {
30
        $mock = new MockHandler($queue);
31
32
        $handler = HandlerStack::create($mock);
33
34
        return new Client(['handler' => $handler]);
35
    }
36
37
    public static function createResponse(\stdClass $stdClass)
38
    {
39
        return new Response(200, ['X-Foo' => 'Bar'], json_encode($stdClass));
40
    }
41
}