GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( 88a33e...2f93d0 )
by Yong
07:13
created

VersionResolver   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
eloc 20
dl 0
loc 74
c 0
b 0
f 0
rs 10
ccs 23
cts 23
cp 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getServiceName() 0 11 2
A __callStatic() 0 3 1
A __construct() 0 3 1
A __call() 0 19 3
1
<?php
2
3
namespace AlibabaCloud;
4
5
use AlibabaCloud\Client\Exception\ClientException;
6
7
class VersionResolver
8
{
9
    /**
10
     * @var bool
11
     */
12
    protected $static = false;
13
14
    /**
15
     * Version Resolver constructor.
16
     *
17
     * @param bool $static
18
     */
19 86
    public function __construct($static = false)
20
    {
21 86
        $this->static = $static;
22 86
    }
23
24
    /**
25
     * @param string $name
26
     * @param array  $arguments
27
     *
28
     * @return mixed
29
     */
30 1
    public static function __callStatic($name, $arguments)
31
    {
32 1
        return (new static(true))->__call($name, $arguments);
33
    }
34
35
    /**
36
     * @param string $version
37
     * @param array  $arguments
38
     *
39
     * @return mixed
40
     * @throws ClientException
41
     */
42 84
    public function __call($version, $arguments)
43
    {
44 84
        $serviceName = $this->getServiceName(\get_class($this));
45
46 84
        $version = \ucfirst($version);
47
48 84
        if ($this->static === true) {
49 1
            $serviceName = \str_replace('Version', '', $serviceName);
50 1
        }
51
52 84
        $class = "AlibabaCloud\\{$serviceName}\\$version\\{$serviceName}ApiResolver";
53
54 84
        if (\class_exists($class)) {
55 83
            return new $class();
56
        }
57
58 1
        throw new ClientException(
59 1
            "$serviceName Versions contains no {$version}",
60
            'SDK.VersionNotFound'
61 1
        );
62
    }
63
64
    /**
65
     * @param string $class
66
     *
67
     * @return mixed
68
     * @throws ClientException
69
     */
70 86
    protected function getServiceName($class)
71
    {
72 86
        $array = \explode('\\', $class);
73
74 86
        if (isset($array[1])) {
75 85
            return $array[1];
76
        }
77
78 1
        throw new ClientException(
79 1
            'Service name not found.',
80
            'SDK.ServiceNotFound'
81 1
        );
82
    }
83
}
84