Passed
Push — master ( 1186c1...cc57e4 )
by Ax
01:41
created

Api::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace SchoppAx\Sleeper\Api;
4
5
use SchoppAx\Sleeper\Http\Client;
6
7
abstract class Api implements ApiInterface
8
{
9
    private $client;
10
11 16
    public function __construct(Client $client)
12
    {
13 16
      $this->client = $client;
14 16
    }
15
16
17
    /**
18
     * @param string $path
19
     * @return json of called api resource
0 ignored issues
show
Bug introduced by
The type SchoppAx\Sleeper\Api\json was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
20
     * @throws Exception
21
     */
22 16
    public function get(string $path)
23
    {
24 16
      $response = $this->client->request('GET', $path);
25
26 15
      if ($response->getStatusCode() !== 200) {
27 1
        throw new \Exception('Client error: `GET '. $path .'` resulted in a '. $response->getStatusCode() .' response');
28 14
      } elseif ($response->getBody()->getSize() === 0) {
29 1
        throw new \Exception('Client error: `GET '. $path .'` resulted in a empty response body');
30
      }
31
32 13
      return json_decode($response->getBody(), true);
33
    }
34
35
}
36