Conditions | 3 |
Paths | 3 |
Total Lines | 20 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 0 |
1 | <?php |
||
27 | private function callApi(string $endpoint, Request $request) |
||
28 | { |
||
29 | $requestMethod = strtolower($request->getMethod()); |
||
30 | $arguments = $request->all(); |
||
31 | $url = "/api/{$endpoint}"; |
||
32 | |||
33 | $methodSupportsArguments = in_array($requestMethod, ['post', 'put', 'patch']); |
||
34 | $callArguments = [$url]; |
||
35 | |||
36 | if (true === $methodSupportsArguments) { |
||
37 | $callArguments = [$url, $arguments]; |
||
38 | |||
39 | return $this->{$requestMethod}(...$callArguments); |
||
40 | } |
||
41 | |||
42 | if (false === empty($arguments)) { |
||
43 | $callArguments = [$url . '?' . http_build_query($arguments)]; |
||
44 | } |
||
45 | |||
46 | return $this->{$requestMethod}(...$callArguments); |
||
47 | } |
||
49 |