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