Total Complexity | 4 |
Total Lines | 39 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
17 | abstract class Entity |
||
18 | { |
||
19 | /** |
||
20 | * @param LinodeClient $client Linode API client. |
||
21 | * @param array $data JSON data retrieved from Linode. |
||
22 | */ |
||
23 | 3 | public function __construct( |
|
24 | protected LinodeClient $client, |
||
25 | protected array $data = [] |
||
26 | 3 | ) {} |
|
27 | |||
28 | /** |
||
29 | * Checks whether the specified property exists in the entity. |
||
30 | * |
||
31 | * @param string $name Property name. |
||
32 | */ |
||
33 | 1 | public function __isset(string $name): bool |
|
34 | { |
||
35 | 1 | return array_key_exists($name, $this->data); |
|
36 | } |
||
37 | |||
38 | /** |
||
39 | * Returns current value of the specified property, or `null` if the property doesn't exist. |
||
40 | * |
||
41 | * @param string $name Property name. |
||
42 | * |
||
43 | * @return null|mixed Property value. |
||
44 | */ |
||
45 | 1 | public function __get(string $name): mixed |
|
48 | } |
||
49 | |||
50 | /** |
||
51 | * Converts the entity into an array. |
||
52 | */ |
||
53 | 1 | public function toArray(): array |
|
56 | } |
||
57 | } |
||
58 |