ClientMock   A
last analyzed

Complexity

Total Complexity 16

Size/Duplication

Total Lines 134
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 16
c 3
b 0
f 0
lcom 1
cbo 0
dl 0
loc 134
rs 10

14 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 4 1
A post() 0 4 1
A put() 0 4 1
A delete() 0 4 1
A patch() 0 4 1
A setHeaders() 0 4 1
A setBody() 0 4 1
A send() 0 4 2
A asJson() 0 4 1
A attach() 0 4 1
A setMock() 0 4 1
A createMock() 0 12 2
A setUserAgent() 0 4 1
A setXRealIP() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the Rutube PHP API Client package.
5
 *
6
 * (c) Rutube
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Rutube\Clients;
13
14
/**
15
 * Mock HTTP-клиент
16
 * @package Rutube\Clients
17
 */
18
class ClientMock implements ClientInterface
19
{
20
    /**
21
     * @var array
22
     */
23
    private static $queue = array();
24
25
    /**
26
     * @param string $uri
27
     * @return $this
28
     */
29
    public function get($uri)
30
    {
31
        return $this;
32
    }
33
34
    /**
35
     * @param string $uri
36
     * @return $this
37
     */
38
    public function post($uri)
39
    {
40
        return $this;
41
    }
42
43
    /**
44
     * @param string $uri
45
     * @return $this
46
     */
47
    public function put($uri)
48
    {
49
        return $this;
50
    }
51
52
    /**
53
     * @param string $uri
54
     * @return $this
55
     */
56
    public function delete($uri)
57
    {
58
        return $this;
59
    }
60
61
    /**
62
     * @param string $uri
63
     * @return $this
64
     */
65
    public function patch($uri)
66
    {
67
        return $this;
68
    }
69
70
    /**
71
     * @param string $token
72
     * @return $this
73
     */
74
    public function setHeaders($token = null)
75
    {
76
        return $this;
77
    }
78
79
    /**
80
     * @param array $body
81
     * @return $this
82
     */
83
    public function setBody($body)
84
    {
85
        return $this;
86
    }
87
88
    /**
89
     * @return \Httpful\associative|string
90
     *
91
     * @throws \Httpful\Exception\ConnectionErrorException
92
     */
93
    public function send()
94
    {
95
        return self::$queue ? array_shift(self::$queue) : self::createMock();
96
    }
97
98
    /**
99
     * @return $this
100
     */
101
    public function asJson()
102
    {
103
        return $this;
104
    }
105
106
    /**
107
     * @param array $files
108
     * @return $this
109
     */
110
    public function attach(array $files)
111
    {
112
        return $this;
113
    }
114
115
    /**
116
     * @param array $params
117
     * @param int $http_code
118
     */
119
    public static function setMock(array $params = array(), $http_code = 200)
120
    {
121
        self::$queue[] = self::createMock($params, $http_code);
122
    }
123
124
    /**
125
     * @param array $params
126
     * @param int $http_code
127
     * @return \stdClass
128
     */
129
    private static function createMock(array $params = array(), $http_code = 200)
130
    {
131
        $obj = new \stdClass();
132
        $obj->body = new \stdClass();
133
        $obj->meta_data = array('http_code' => $http_code);
134
135
        foreach ($params as $key => $value) {
136
            $obj->body->{$key} = $value;
137
        }
138
139
        return $obj;
140
    }
141
142
    public function setUserAgent($userAgent)
143
    {
144
        return $this;
145
    }
146
147
    public function setXRealIP($ip)
148
    {
149
        return $this;
150
    }
151
}
152