| 1 | <?php |
||
| 18 | class Route extends AnnotationWithValue implements ClassInterface, MethodInterface |
||
| 19 | { |
||
| 20 | /** @var string Route path */ |
||
| 21 | protected $path; |
||
| 22 | |||
| 23 | /** @var string Route identifier */ |
||
| 24 | protected $identifier; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Route constructor. |
||
| 28 | * |
||
| 29 | * @param array $valueOrValues |
||
| 30 | * |
||
| 31 | * @throws \InvalidArgumentException |
||
| 32 | */ |
||
| 33 | 6 | public function __construct($valueOrValues) |
|
| 34 | { |
||
| 35 | 6 | parent::__construct($valueOrValues); |
|
| 36 | |||
| 37 | 6 | if (!array_key_exists('value', $valueOrValues) || $valueOrValues['value'] === '') { |
|
| 38 | 1 | throw new \InvalidArgumentException('@Route annotation should have value'); |
|
| 39 | } |
||
| 40 | |||
| 41 | // Set data |
||
| 42 | 5 | $this->path = $valueOrValues['value'] ?? null; |
|
| 43 | 5 | $this->identifier = $valueOrValues['name'] ?? uniqid(__CLASS__, true); |
|
| 44 | 5 | } |
|
| 45 | |||
| 46 | /** |
||
| 47 | * {@inheritDoc} |
||
| 48 | */ |
||
| 49 | 3 | public function toMethodMetadata(MethodMetadata $methodMetadata) |
|
| 53 | |||
| 54 | /** |
||
| 55 | * {@inheritDoc} |
||
| 56 | */ |
||
| 57 | 3 | public function toClassMetadata(ClassMetadata $classMetadata) |
|
| 61 | } |
||
| 62 |