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   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 19
c 1
b 0
f 0
dl 0
loc 59
rs 10
wmc 8

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __callStatic() 0 3 1
A __call() 0 19 4
A getProductName() 0 11 3
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