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

VersionResolver   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 58
rs 10
c 0
b 0
f 0
wmc 7

3 Methods

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