1 | <?php |
||
17 | class Api |
||
18 | { |
||
19 | /** |
||
20 | * Holds the provided email address for API authentication |
||
21 | * |
||
22 | * @var string |
||
23 | */ |
||
24 | public $email; |
||
25 | |||
26 | /** |
||
27 | * Holds the provided auth_key for API authentication |
||
28 | * |
||
29 | * @var string |
||
30 | */ |
||
31 | public $auth_key; |
||
32 | |||
33 | /** |
||
34 | * Holds the curl options |
||
35 | * |
||
36 | * @var array |
||
37 | */ |
||
38 | public $curl_options; |
||
39 | |||
40 | /** |
||
41 | * Make a new instance of the API client |
||
42 | * This can be done via providing the email address and api key as seperate parameters |
||
43 | * or by passing in an already instantiated object from which the details will be extracted |
||
44 | */ |
||
45 | public function __construct() |
||
60 | |||
61 | /** |
||
62 | * Setter to allow the setting of the email address |
||
63 | * |
||
64 | * @param string $email The email address associated with the Cloudflare account |
||
65 | */ |
||
66 | public function setEmail($email) |
||
70 | |||
71 | /** |
||
72 | * Setter to allow the setting of the Authentication Key |
||
73 | * |
||
74 | * @param string $token Authentication key, this can be retrieve from the 'My Account' section of the Cloudflare account |
||
75 | */ |
||
76 | public function setAuthKey($token) |
||
80 | |||
81 | /** |
||
82 | * Setter to allow the adding / changing of the Curl options that will be used within the HTTP requests |
||
83 | * |
||
84 | * @param int $key The CURLOPT_XXX option to set e.g. CURLOPT_TIMEOUT |
||
85 | * @param mixed $value The value to be set on option e.g. 10 |
||
86 | */ |
||
87 | public function setCurlOption($key, $value) |
||
91 | |||
92 | /** |
||
93 | * API call method for sending requests using GET |
||
94 | * |
||
95 | * @param string $path Path of the endpoint |
||
96 | * @param array|null $data Data to be sent along with the request |
||
97 | * |
||
98 | * @return mixed |
||
99 | */ |
||
100 | public function get($path, array $data = null) |
||
104 | |||
105 | /** |
||
106 | * API call method for sending requests using POST |
||
107 | * |
||
108 | * @param string $path Path of the endpoint |
||
109 | * @param array|null $data Data to be sent along with the request |
||
110 | * |
||
111 | * @return mixed |
||
112 | */ |
||
113 | public function post($path, array $data = null) |
||
117 | |||
118 | /** |
||
119 | * API call method for sending requests using PUT |
||
120 | * |
||
121 | * @param string $path Path of the endpoint |
||
122 | * @param array|null $data Data to be sent along with the request |
||
123 | * |
||
124 | * @return mixed |
||
125 | */ |
||
126 | public function put($path, array $data = null) |
||
130 | |||
131 | /** |
||
132 | * API call method for sending requests using DELETE |
||
133 | * |
||
134 | * @param string $path Path of the endpoint |
||
135 | * @param array|null $data Data to be sent along with the request |
||
136 | * |
||
137 | * @return mixed |
||
138 | */ |
||
139 | public function delete($path, array $data = null) |
||
143 | |||
144 | /** |
||
145 | * API call method for sending requests using PATCH |
||
146 | * |
||
147 | * @param string $path Path of the endpoint |
||
148 | * @param array|null $data Data to be sent along with the request |
||
149 | * |
||
150 | * @return mixed |
||
151 | */ |
||
152 | public function patch($path, array $data = null) |
||
156 | |||
157 | /** |
||
158 | * @codeCoverageIgnore |
||
159 | * |
||
160 | * API call method for sending requests using GET, POST, PUT, DELETE OR PATCH |
||
161 | * |
||
162 | * @param string $path Path of the endpoint |
||
163 | * @param array|null $data Data to be sent along with the request |
||
164 | * @param string|null $method Type of method that should be used ('GET', 'POST', 'PUT', 'DELETE', 'PATCH') |
||
165 | * |
||
166 | * @return mixed |
||
167 | */ |
||
168 | protected function request($path, array $data = array(), $method = 'get') |
||
248 | } |
||
249 |
This check looks at variables that have been passed in as parameters and are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.