1
1
<?php
2
2
/**
3
- * PHP-Firebase
3
+ * PHP-Firebase.
4
4
*
5
5
* @link https://github.com/adrorocker/php-firebase
6
+ *
6
7
* @copyright Copyright (c) 2018 Adro Rocker
7
8
* @author Adro Rocker <mes@adro.rocks>
8
9
*/
10
+
9
11
namespace PhpFirebase \Clients ;
10
12
11
- use InvalidArgumentException ;
12
- use PhpFirebase \Interfaces \ClientInterface ;
13
13
use GuzzleHttp \Client as HttpClient ;
14
- use GuzzleHttp \Exception \ClientException ;
15
14
use GuzzleHttp \Psr7 \Request ;
16
15
use GuzzleHttp \Psr7 \Response ;
17
- use GuzzleHttp \ Psr7 \ Uri ;
16
+ use PhpFirebase \ Interfaces \ ClientInterface ;
18
17
use function GuzzleHttp \Psr7 \stream_for ;
19
18
20
19
/**
21
20
* Guzzle Client.
22
21
*
23
- * @package PhpFirebase
24
- * @subpackage Clients
25
22
* @since 0.1.0
26
23
*/
27
24
class GuzzleClient implements ClientInterface
28
25
{
29
26
/**
30
- * Guzzle client
27
+ * Guzzle client.
31
28
*
32
29
* @var \GuzzleHttp\Client
33
30
*/
34
31
protected $ guzzle ;
35
32
36
33
/**
37
- * Set the the guzzle client
34
+ * Set the the guzzle client.
38
35
*
39
- * @param array $options The options to set the defaul
40
- * @param Object |null $client Client to make the requests
36
+ * @param array $options The options to set the defaul
37
+ * @param object |null $client Client to make the requests
41
38
*/
42
39
public function __construct (array $ options = [], $ client = null )
43
40
{
44
41
if (!$ client ) {
45
42
$ client = new HttpClient ($ options );
46
43
}
47
-
44
+
48
45
$ this ->guzzle = $ client ;
49
46
}
50
47
51
48
/**
52
- * Create a new GET reuest
49
+ * Create a new GET reuest.
53
50
*
54
51
* @param string $endpoint The sub endpoint
55
- * @param array $headers Request headers
52
+ * @param array $headers Request headers
56
53
*
57
54
* @return array
58
55
*/
@@ -66,11 +63,11 @@ public function get($endpoint, $headers = [])
66
63
}
67
64
68
65
/**
69
- * Create a new POST reuest
66
+ * Create a new POST reuest.
70
67
*
71
- * @param string $endpoint The sub endpoint
72
- * @param string|array $data The data to be submited
73
- * @param array $headers Request headers
68
+ * @param string $endpoint The sub endpoint
69
+ * @param string|array $data The data to be submited
70
+ * @param array $headers Request headers
74
71
*
75
72
* @return array
76
73
*/
@@ -84,11 +81,11 @@ public function post($endpoint, $data, $headers = [])
84
81
}
85
82
86
83
/**
87
- * Create a new PUT reuest
84
+ * Create a new PUT reuest.
88
85
*
89
- * @param string $endpoint The sub endpoint
90
- * @param string|array $data The data to be submited
91
- * @param array $headers Request headers
86
+ * @param string $endpoint The sub endpoint
87
+ * @param string|array $data The data to be submited
88
+ * @param array $headers Request headers
92
89
*
93
90
* @return array
94
91
*/
@@ -102,11 +99,11 @@ public function put($endpoint, $data, $headers = [])
102
99
}
103
100
104
101
/**
105
- * Create a new PATCH reuest
102
+ * Create a new PATCH reuest.
106
103
*
107
- * @param string $endpoint The sub endpoint
108
- * @param string|array $data The data to be submited
109
- * @param array $headers Request headers
104
+ * @param string $endpoint The sub endpoint
105
+ * @param string|array $data The data to be submited
106
+ * @param array $headers Request headers
110
107
*
111
108
* @return array
112
109
*/
@@ -120,10 +117,10 @@ public function patch($endpoint, $data, $headers = [])
120
117
}
121
118
122
119
/**
123
- * Create a new DELETE reuest
120
+ * Create a new DELETE reuest.
124
121
*
125
122
* @param string $endpoint The sub endpoint
126
- * @param array $headers Request headers
123
+ * @param array $headers Request headers
127
124
*
128
125
* @return array
129
126
*/
@@ -136,10 +133,8 @@ public function delete($endpoint, $headers = [])
136
133
return $ this ->handle ($ response );
137
134
}
138
135
139
-
140
-
141
136
/**
142
- * Handle the response
137
+ * Handle the response.
143
138
*
144
139
* @param \GuzzleHttp\Psr7\Response $response The response
145
140
*
0 commit comments