Passed
Push — master ( b16a12...abed16 )
by Ax
09:12
created

Api   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 26
ccs 8
cts 10
cp 0.8
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A get() 0 11 3
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 $client;
10
11 1
    public function __construct(Client $client)
12
    {
13 1
      $this->client = $client;
14 1
    }
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 SleeperException
21
     */
22 1
    public function get(string $path)
23
    {
24 1
      $response = $this->client->request('GET', $path);
25
26 1
      if ($response->getStatusCode() !== 200) {
27
        throw new SleeperHttpException($response->getStatusCode());
28 1
      } elseif ($response->getBody() === 'null') {
0 ignored issues
show
introduced by
The condition $response->getBody() === 'null' is always false.
Loading history...
29
        throw new NullPointerException('The $var does not exist');
0 ignored issues
show
Bug introduced by
The type SchoppAx\Sleeper\Api\NullPointerException 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...
30
      }
31
32 1
      return json_decode($response->getBody(), true);
33
    }
34
35
}
36