| @@ 10-55 (lines=46) @@ | ||
| 7 | * @Annotation  | 
                                |
| 8 |  * @Target({"CLASS"}) | 
                                |
| 9 | */  | 
                                |
| 10 | class Collection  | 
                                |
| 11 | { | 
                                |
| 12 | /**  | 
                                |
| 13 | * @var array  | 
                                |
| 14 | */  | 
                                |
| 15 | protected $types = [];  | 
                                |
| 16 | ||
| 17 | /**  | 
                                |
| 18 | * Nested constructor.  | 
                                |
| 19 | * @param array $types  | 
                                |
| 20 | */  | 
                                |
| 21 | public function __construct(array $types)  | 
                                |
| 22 |     { | 
                                |
| 23 | $this->types = $types;  | 
                                |
| 24 | }  | 
                                |
| 25 | ||
| 26 | /**  | 
                                |
| 27 | * @return array  | 
                                |
| 28 | */  | 
                                |
| 29 | public function properties(): array  | 
                                |
| 30 |     { | 
                                |
| 31 | return array_keys($this->types);  | 
                                |
| 32 | }  | 
                                |
| 33 | ||
| 34 | /**  | 
                                |
| 35 | * @param $key  | 
                                |
| 36 | * @return bool  | 
                                |
| 37 | */  | 
                                |
| 38 | public function has($key): bool  | 
                                |
| 39 |     { | 
                                |
| 40 | return isset($this->types[$key]);  | 
                                |
| 41 | }  | 
                                |
| 42 | ||
| 43 | /**  | 
                                |
| 44 | * @param $key  | 
                                |
| 45 | * @return string  | 
                                |
| 46 | */  | 
                                |
| 47 | public function get($key): string  | 
                                |
| 48 |     { | 
                                |
| 49 |         if (!$this->has($key)) { | 
                                |
| 50 | throw new \InvalidArgumentException();  | 
                                |
| 51 | }  | 
                                |
| 52 | ||
| 53 | return $this->types[$key];  | 
                                |
| 54 | }  | 
                                |
| 55 | }  | 
                                |
| 56 | ||
| @@ 10-55 (lines=46) @@ | ||
| 7 | * @Annotation  | 
                                |
| 8 |  * @Target({"CLASS"}) | 
                                |
| 9 | */  | 
                                |
| 10 | class Nested  | 
                                |
| 11 | { | 
                                |
| 12 | /**  | 
                                |
| 13 | * @var array  | 
                                |
| 14 | */  | 
                                |
| 15 | protected $nestedObjects = [];  | 
                                |
| 16 | ||
| 17 | /**  | 
                                |
| 18 | * Nested constructor.  | 
                                |
| 19 | * @param array $nestedObjects  | 
                                |
| 20 | */  | 
                                |
| 21 | public function __construct(array $nestedObjects)  | 
                                |
| 22 |     { | 
                                |
| 23 | $this->nestedObjects = $nestedObjects;  | 
                                |
| 24 | }  | 
                                |
| 25 | ||
| 26 | /**  | 
                                |
| 27 | * @return array  | 
                                |
| 28 | */  | 
                                |
| 29 | public function properties(): array  | 
                                |
| 30 |     { | 
                                |
| 31 | return array_keys($this->nestedObjects);  | 
                                |
| 32 | }  | 
                                |
| 33 | ||
| 34 | /**  | 
                                |
| 35 | * @param $key  | 
                                |
| 36 | * @return bool  | 
                                |
| 37 | */  | 
                                |
| 38 | public function has($key): bool  | 
                                |
| 39 |     { | 
                                |
| 40 | return isset($this->nestedObjects[$key]);  | 
                                |
| 41 | }  | 
                                |
| 42 | ||
| 43 | /**  | 
                                |
| 44 | * @param $key  | 
                                |
| 45 | * @return string  | 
                                |
| 46 | */  | 
                                |
| 47 | public function get($key): string  | 
                                |
| 48 |     { | 
                                |
| 49 |         if (!$this->has($key)) { | 
                                |
| 50 | throw new \InvalidArgumentException();  | 
                                |
| 51 | }  | 
                                |
| 52 | ||
| 53 | return $this->nestedObjects[$key];  | 
                                |
| 54 | }  | 
                                |
| 55 | }  | 
                                |
| 56 | ||