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.

VersionResolver::__call()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

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