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 ( a66aaf...9db01e )
by Yong
03:49
created

ApiResolver::__callStatic()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace AlibabaCloud\Client\Resolver;
4
5
use AlibabaCloud\Client\Exception\ClientException;
6
7
/**
8
 * Class ApiResolver
9
 *
10
 * @internal
11
 * @codeCoverageIgnore
12
 * @package AlibabaCloud\Client\Resolver
13
 */
14
abstract class ApiResolver
15
{
16
17
    /**
18
     * @param $name
19
     * @param $arguments
20
     *
21
     * @return mixed
22
     */
23
    public static function __callStatic($name, $arguments)
24
    {
25
        return (new static())->__call($name, $arguments);
26
    }
27
28
    /**
29
     * @param $api
30
     * @param $arguments
31
     *
32
     * @return mixed
33
     * @throws ClientException
34
     */
35
    public function __call($api, $arguments)
36
    {
37
        $product_name = $this->getProductName();
38
        $class        = $this->getNamespace() . '\\' . \ucfirst($api);
39
40
        if (\class_exists($class)) {
41
            if (isset($arguments[0])) {
42
                return new $class($arguments[0]);
43
            }
44
45
            return new $class();
46
        }
47
48
        throw new ClientException(
49
            "{$product_name} contains no $api",
50
            'SDK.ApiNotFound'
51
        );
52
    }
53
54
    /**
55
     * @return mixed
56
     * @throws ClientException
57
     */
58
    private function getProductName()
59
    {
60
        $array = \explode('\\', \get_class($this));
61
        if (isset($array[3])) {
62
            return str_replace('ApiResolver', '', $array[3]);
63
        }
64
        throw new ClientException(
65
            'Service name not found.',
66
            'SDK.ServiceNotFound'
67
        );
68
    }
69
70
    /**
71
     * @return string
72
     * @throws ClientException
73
     */
74
    private function getNamespace()
75
    {
76
        $array = \explode('\\', \get_class($this));
77
78
        if (!isset($array[3])) {
79
            throw new ClientException(
80
                'Get namespace error.',
81
                'SDK.ParseError'
82
            );
83
        }
84
85
        unset($array[3]);
86
87
        return \implode('\\', $array);
88
    }
89
}
90