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

Sleeper   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 90%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getApiInstance() 0 8 2
A __call() 0 3 1
1
<?php
2
3
namespace SchoppAx\Sleeper;
4
5
use SchoppAx\Sleeper\Http\Client;
6
7
class Sleeper
8
{
9
  private Client $client;
10
11 1
  public function __construct($mock = NULL)
12
  {
13 1
    $this->client = new Client($mock);
14 1
  }
15
16
  /**
17
   * @param string $method
18
   * @param string $parameters
19
   * @return class
0 ignored issues
show
Bug introduced by
The type SchoppAx\Sleeper\class 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 BadMethodCallException
21
   */
22 1
  public function __call($method, array $parameters = [])
23
  {
24 1
    return $this->getApiInstance($method);
25
  }
26
27 1
  protected function getApiInstance($method): object
28
  {
29 1
    $class = "\\SchoppAx\\Sleeper\\Api\\".ucwords($method);
30
31 1
    if (class_exists($class)) {
32 1
        return new $class($this->client);
33
    }
34
    throw new \BadMethodCallException("Undefined method [{$method}] called.");
35
  }
36
37
}
38