1 | <?php |
||
6 | class TargetName |
||
7 | { |
||
8 | const PATTERN = <<<'REGEXP' |
||
9 | ([a-zA-Z_][a-zA-Z0-9_-]*)((?:\[\d*\])*)(\?)? |
||
10 | REGEXP; |
||
11 | |||
12 | 18 | static public function parse(string $target): TargetName |
|
30 | |||
31 | /** @var string */ |
||
32 | protected $name; |
||
33 | |||
34 | /** @var array */ |
||
35 | protected $iterator; |
||
36 | |||
37 | /** @var bool */ |
||
38 | protected $optional; |
||
39 | |||
40 | 17 | public function __construct(string $name, array $iterator = [], bool $optional) |
|
46 | |||
47 | /** |
||
48 | * @return string |
||
49 | */ |
||
50 | 17 | public function getName(): string |
|
54 | |||
55 | /** |
||
56 | * @return array |
||
57 | */ |
||
58 | 17 | public function getIterator(): array |
|
62 | |||
63 | /** |
||
64 | * @return boolean |
||
65 | */ |
||
66 | 17 | public function isOptional(): bool |
|
70 | } |
||
71 |