1 | <?php |
||
11 | class AbstractApi |
||
12 | { |
||
13 | /** |
||
14 | * @var ClientInterface HTTP-client from Guzzle |
||
15 | */ |
||
16 | protected $client; |
||
17 | |||
18 | /** |
||
19 | * @var string Authentication token for API |
||
20 | */ |
||
21 | protected $authToken; |
||
22 | |||
23 | /** |
||
24 | * @var string CSRF-token for API |
||
25 | */ |
||
26 | protected $csRfToken; |
||
27 | |||
28 | |||
29 | public function __construct(ClientInterface $httpClient) |
||
33 | |||
34 | /** |
||
35 | * @param string $path Request path |
||
36 | * @param array $parameters Key => Value array of query parameters |
||
37 | * |
||
38 | * @return ResponseInterface |
||
39 | */ |
||
40 | public function sendGetRequest(string $path, array $parameters = []): ResponseInterface |
||
44 | 12 | ||
45 | 12 | /** |
|
46 | * @param string $path Request path |
||
47 | 12 | * @param array $parameters Key => Value array of request data |
|
48 | 12 | * |
|
49 | * @return ResponseInterface |
||
50 | 12 | */ |
|
51 | public function sendPostRequest(string $path, array $parameters = []): ResponseInterface |
||
55 | |||
56 | /** |
||
57 | * Make GET request and return data from response |
||
58 | * |
||
59 | * @param string $path Path template |
||
60 | * @param array $parameters Parameters array used to fill path template |
||
61 | * @param bool $decodeJsonResponse Decode JSON or return plaintext |
||
62 | * @param bool $decodeJsonToObjects Decode JSON objects to PHP objects instead of arrays |
||
63 | * |
||
64 | * @return mixed |
||
65 | */ |
||
66 | public function getGetRequestData($path, array $parameters = [], bool $decodeJsonResponse = false, bool $decodeJsonToObjects = false) |
||
72 | |||
73 | /** |
||
74 | * Make POST request and return data from response |
||
75 | * |
||
76 | * @param string $path Path template |
||
77 | * @param array $parameters Parameters array used to fill path template |
||
78 | * @param bool $decodeJson Decode JSON or return plaintext |
||
79 | * @param bool $decodeToObjects Decode JSON objects to PHP objects instead of arrays |
||
80 | * |
||
81 | * @return mixed |
||
82 | */ |
||
83 | public function getPostRequestData($path, array $parameters = [], bool $decodeJson = false, bool $decodeToObjects = false) |
||
89 | |||
90 | /** |
||
91 | * Get HTTP client base URL |
||
92 | * |
||
93 | * @return string Base URL of client |
||
94 | */ |
||
95 | public function getBaseUrl(): string |
||
99 | |||
100 | /** |
||
101 | * @param ResponseInterface $response |
||
102 | * @param bool $decodeJson |
||
103 | * @param bool $decodeToObjects |
||
104 | * |
||
105 | * @return string|array|object |
||
106 | */ |
||
107 | private function processResponse(ResponseInterface $response, bool $decodeJson = false, bool $decodeToObjects = false) |
||
119 | } |
||
120 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.