Total Complexity | 5 |
Total Lines | 47 |
Duplicated Lines | 0 % |
Coverage | 42.86% |
Changes | 0 |
1 | <?php |
||
12 | class ArrayResponse extends \ArrayObject implements ResponseInterface |
||
13 | { |
||
14 | private $name; |
||
15 | |||
16 | /** |
||
17 | * @param string $name |
||
18 | * @param array $data |
||
19 | */ |
||
20 | 54 | public function __construct(string $name, array $data) |
|
21 | { |
||
22 | 54 | $this->name = $name; |
|
23 | 54 | parent::__construct($data); |
|
24 | 54 | } |
|
25 | |||
26 | 45 | public function getResponseName(): string |
|
29 | } |
||
30 | |||
31 | /** |
||
32 | * Object property access to ArrayObject data. |
||
33 | */ |
||
34 | public function __get($property) |
||
35 | { |
||
36 | $key = $this->transformPropertyName($property); |
||
37 | |||
38 | return $this[$key] ?? null; |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * Object property access to ArrayObject data. |
||
43 | */ |
||
44 | public function __isset($property) |
||
49 | } |
||
50 | |||
51 | // ---------------------------------------- |
||
52 | |||
53 | /** |
||
54 | * Tranform underscored property name to hyphenated array key. |
||
55 | */ |
||
56 | private function transformPropertyName(string $propertyName): string |
||
61 |