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 ( 5776d5...11ab91 )
by Yong
04:48
created

CallTrait::getCallArguments()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 3
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace AlibabaCloud\Client\Resolver;
4
5
use RuntimeException;
6
use ArgumentCountError;
7
8
/**
9
 * Trait CallTrait
10
 *
11
 * @codeCoverageIgnore
12
 * @package AlibabaCloud\Client\Resolver
13
 */
14
trait CallTrait
15
{
16
    /**
17
     * Magic method for set or get request parameters.
18
     *
19
     * @param string $name
20
     * @param mixed  $arguments
21
     *
22
     * @return $this
23
     */
24
    public function __call($name, $arguments)
25
    {
26
        if (strncmp($name, 'get', 3) === 0) {
27
            $parameter = \mb_strcut($name, 3);
28
29
            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

29
            return $this->/** @scrutinizer ignore-call */ __get($parameter);
Loading history...
30
        }
31
32
        if (strncmp($name, 'with', 4) === 0) {
33
            $parameter = \mb_strcut($name, 4);
34
35
            $value                                 = $this->getCallArguments($name, $arguments);
36
            $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...
37
            $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

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