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

MockClient   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 5
dl 0
loc 19
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getClient() 0 7 1
A createResponse() 0 3 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
}