Completed
Push — master ( b30e7c...cca158 )
by Julien
02:44 queued 25s
created

Guzzle::patch()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 3
1
<?php
2
3
namespace CanalTP\AbstractGuzzle;
4
5
use GuzzleHttp\Psr7\Request;
6
use GuzzleHttp\Psr7\Response;
7
8
abstract class Guzzle
9
{
10
    /**
11
     * @var string
12
     */
13
    private $baseUri;
14
15
    /**
16
     * @param string $baseUri
17
     */
18
    public function __construct($baseUri)
19
    {
20
        $this->baseUri = $baseUri;
21
    }
22
23
    /**
24
     * @return string
25
     */
26
    public function getBaseUri()
27
    {
28
        return $this->baseUri;
29
    }
30
31
    /**
32
     * @param string $baseUri
33
     *
34
     * @return self
35
     */
36
    public function setBaseUri($baseUri)
37
    {
38
        $this->baseUri = $baseUri;
39
40
        return $this;
41
    }
42
43
    /**
44
     * @param Request $request
45
     *
46
     * @return Response
47
     */
48
    abstract public function send(Request $request);
49
50
    /**
51
     * @param string $method
52
     * @param string $uri
53
     * @param string[] $headers
54
     * @param string $body
55
     *
56
     * @return Response
57
     */
58
    public function call($method, $uri, $headers = array(), $body = null)
59
    {
60
        $request = new Request($method, $uri, $headers, $body);
61
62
        $response = $this->send($request);
63
64
        return $response;
65
    }
66
67
    /**
68
     * @param string $uri
69
     * @param string[] $headers
70
     * @param string $body
71
     *
72
     * @return Response
73
     */
74
    public function get($uri, $headers = array(), $body = null)
75
    {
76
        return $this->call('get', $uri, $headers, $body);
77
    }
78
79
    /**
80
     * @param string $uri
81
     * @param string[] $headers
82
     * @param string $body
83
     *
84
     * @return Response
85
     */
86
    public function post($uri, $headers = array(), $body = null)
87
    {
88
        return $this->call('post', $uri, $headers, $body);
89
    }
90
91
    /**
92
     * @param string $uri
93
     * @param string[] $headers
94
     * @param string $body
95
     *
96
     * @return Response
97
     */
98
    public function put($uri, $headers = array(), $body = null)
99
    {
100
        return $this->call('put', $uri, $headers, $body);
101
    }
102
103
    /**
104
     * @param string $uri
105
     * @param string[] $headers
106
     * @param string $body
107
     *
108
     * @return Response
109
     */
110
    public function patch($uri, $headers = array(), $body = null)
111
    {
112
        return $this->call('patch', $uri, $headers, $body);
113
    }
114
115
    /**
116
     * @param string $uri
117
     * @param string[] $headers
118
     * @param string $body
119
     *
120
     * @return Response
121
     */
122
    public function delete($uri, $headers = array(), $body = null)
123
    {
124
        return $this->call('delete', $uri, $headers, $body);
125
    }
126
127
    /**
128
     * @param string $uri
129
     * @param string[] $headers
130
     * @param string $body
131
     *
132
     * @return Response
133
     */
134
    public function head($uri, $headers = array(), $body = null)
135
    {
136
        return $this->call('head', $uri, $headers, $body);
137
    }
138
}
139