Passed
Push — master ( 744134...9f7edb )
by Ax
01:44
created

SleeperClient   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
c 0
b 0
f 0
dl 0
loc 35
rs 10
ccs 10
cts 10
cp 1
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getApiInstance() 0 8 2
A __construct() 0 3 1
A __call() 0 3 1
1
<?php
2
3
namespace SchoppAx\Sleeper;
4
5
use SchoppAx\Sleeper\Http\Client;
6
7
class SleeperClient
8
{
9
  private Client $client;
10
11 8
  public function __construct($mock = NULL)
12
  {
13 8
    $this->client = new Client($mock);
14 8
  }
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
   *
21
   * @method class Avatars() retrieves avatar images for users and leagues
22
   * @method class Drafts() retrieves all drafts by a user or league
23
   * @method class leagues() retrieves all leagues
24
   * @method class Players() retrieves all players
25
   * @method class Users() retrieve user object by name or id
26
   *
27
   * @throws BadMethodCallException
28
   */
29 8
  public function __call($method, array $parameters = [])
30
  {
31 8
    return $this->getApiInstance($method);
32
  }
33
34 8
  protected function getApiInstance($method): object
35
  {
36 8
    $class = "\\SchoppAx\\Sleeper\\Api\\".ucwords($method);
37
38 8
    if (class_exists($class)) {
39 7
        return new $class($this->client);
40
    }
41 1
    throw new \BadMethodCallException("Undefined method [{$method}] called.");
42
  }
43
44
}
45