Total Complexity | 3 |
Total Lines | 55 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
12 | class Method implements JsonSerializable, Stringable |
||
13 | { |
||
14 | /** |
||
15 | * The name of the javascript function |
||
16 | * |
||
17 | * @var string |
||
18 | */ |
||
19 | private $sName; |
||
20 | |||
21 | /** |
||
22 | * @var array<ParameterInterface> |
||
23 | */ |
||
24 | private $aParameters = []; |
||
25 | |||
26 | /** |
||
27 | * The constructor. |
||
28 | * |
||
29 | * @param string $sName The method name |
||
30 | * @param array $aArguments The method arguments |
||
31 | */ |
||
32 | public function __construct(string $sName, array $aArguments) |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * Convert this call to array, when converting the response into json. |
||
42 | * |
||
43 | * @return array |
||
44 | */ |
||
45 | public function jsonSerialize(): array |
||
46 | { |
||
47 | return [ |
||
48 | '_type' => 'method', |
||
49 | '_name' => $this->sName, |
||
50 | 'args' => array_map(function(JsonSerializable $xParam) { |
||
51 | return $xParam->jsonSerialize(); |
||
52 | }, $this->aParameters), |
||
53 | ]; |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * Returns a string representation of this call |
||
58 | * |
||
59 | * @return string |
||
60 | */ |
||
61 | public function __toString(): string |
||
67 | } |
||
68 | } |
||
69 |