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.

CallTrait::__call()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 26
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 4
eloc 14
c 3
b 0
f 0
nc 4
nop 2
dl 0
loc 26
rs 9.7998
1
<?php
2
3
namespace AlibabaCloud\Client\Resolver;
4
5
use RuntimeException;
6
7
/**
8
 * Trait CallTrait
9
 *
10
 * @codeCoverageIgnore
11
 * @package AlibabaCloud\Client\Resolver
12
 */
13
trait CallTrait
14
{
15
    /**
16
     * Magic method for set or get request parameters.
17
     *
18
     * @param string $name
19
     * @param mixed  $arguments
20
     *
21
     * @return $this
22
     */
23
    public function __call($name, $arguments)
24
    {
25
        if (strncmp($name, 'get', 3) === 0) {
26
            $parameter = \mb_strcut($name, 3);
27
28
            return $this->__get($parameter);
0 ignored issues
show
Bug introduced by
The method __get() does not exist on AlibabaCloud\Client\Resolver\CallTrait. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

28
            return $this->/** @scrutinizer ignore-call */ __get($parameter);
Loading history...
29
        }
30
31
        if (strncmp($name, 'with', 4) === 0) {
32
            $parameter = \mb_strcut($name, 4);
33
34
            $value                                 = $this->getCallArguments($name, $arguments);
35
            $this->data[$parameter]                = $value;
0 ignored issues
show
Bug Best Practice introduced by
The property data does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
36
            $this->parameterPosition()[$parameter] = $value;
0 ignored issues
show
Bug introduced by
The method parameterPosition() does not exist on AlibabaCloud\Client\Resolver\CallTrait. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

36
            $this->/** @scrutinizer ignore-call */ 
37
                   parameterPosition()[$parameter] = $value;
Loading history...
37
38
            return $this;
39
        }
40
41
        if (strncmp($name, 'set', 3) === 0) {
42
            $parameter   = \mb_strcut($name, 3);
43
            $with_method = "with$parameter";
44
45
            return $this->$with_method($this->getCallArguments($name, $arguments));
46
        }
47
48
        throw new RuntimeException('Call to undefined method ' . __CLASS__ . '::' . $name . '()');
49
    }
50
51
    /**
52
     * @param string $name
53
     * @param array  $arguments
54
     * @param int    $index
55
     *
56
     * @return mixed
57
     */
58
    private function getCallArguments($name, array $arguments, $index = 0)
59
    {
60
        if (!isset($arguments[$index])) {
61
            throw new \InvalidArgumentException("Missing arguments to method $name");
62
        }
63
64
        return $arguments[$index];
65
    }
66
}
67