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 = $this->propertyNameByMethodName($name); |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
27 | |||
28 | return $this->__get($parameter); |
||
29 | } |
||
30 | |||
31 | if (strncmp($name, 'with', 4) === 0) { |
||
32 | $parameter = $this->propertyNameByMethodName($name, 4); |
||
33 | |||
34 | $value = $arguments[0]; |
||
35 | $this->data[$parameter] = $value; |
||
36 | $this->parameterPosition()[$parameter] = $value; |
||
37 | |||
38 | return $this; |
||
39 | } |
||
40 | |||
41 | if (strncmp($name, 'set', 3) === 0) { |
||
42 | $parameter = $this->propertyNameByMethodName($name); |
||
43 | $with_method = "with$parameter"; |
||
44 | |||
45 | return $this->$with_method($arguments[0]); |
||
46 | } |
||
47 | |||
48 | throw new RuntimeException('Call to undefined method ' . __CLASS__ . '::' . $name . '()'); |
||
49 | } |
||
50 | } |
||
51 |