GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

MockCollection   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 7
lcom 1
cbo 2
dl 0
loc 57
rs 10
c 1
b 0
f 1

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getInstance() 0 9 2
A has() 0 4 1
A getMockResponse() 0 9 1
A add() 0 9 1
A clear() 0 4 1
1
<?php
2
3
namespace ShippoClient\Http\Request;
4
5
use Guzzle\Http\Message\Response;
6
use Guzzle\Plugin\Mock\MockPlugin;
7
8
class MockCollection
9
{
10
    /**
11
     * @var static|null
12
     */
13
    private static $instance = null;
14
15
    private static $container = [];
16
17
    private function __construct()
18
    {
19
    }
20
21
    public static function getInstance()
22
    {
23
        if (self::$instance !== null) {
24
            return self::$instance;
25
        }
26
        self::$instance = new self();
27
28
        return self::$instance;
29
    }
30
31
    public function has($endPoint)
32
    {
33
        return array_key_exists($endPoint, self::$container);
34
    }
35
36
    /**
37
     * @param string $endPoint
38
     * @return MockPlugin
39
     */
40
    public function getMockResponse($endPoint)
41
    {
42
        $response = new Response(self::$container[$endPoint]['statusCode']);
43
        $response->setBody(json_encode(self::$container[$endPoint]['response']));
44
        $mock = new MockPlugin();
45
        $mock->addResponse($response);
46
47
        return $mock;
48
    }
49
50
    public function add($path, $statusCode, $response)
51
    {
52
        self::$container[$path] = [
53
            'statusCode' => $statusCode,
54
            'response'   => $response,
55
        ];
56
57
        return $this;
58
    }
59
60
    public function clear()
61
    {
62
        self::$container = [];
63
    }
64
}
65