| 1 | <?php |
||
| 18 | trait RouteConstructorTrait |
||
| 19 | { |
||
| 20 | /** |
||
| 21 | * @var string |
||
| 22 | */ |
||
| 23 | private $path; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @var string |
||
| 27 | */ |
||
| 28 | private $spec; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * {@inheritdoc} |
||
| 32 | * @see \WebinoConfigLib\Router\Route\Regex\RouteConstructorInterface |
||
| 33 | */ |
||
| 34 | public function __construct($path, $spec = null) |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @param string $type Route type. |
||
| 45 | * @return $this |
||
| 46 | */ |
||
| 47 | abstract public function setType($type = RouteInterface::LITERAL); |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Initialize route |
||
| 51 | * |
||
| 52 | * @return void |
||
| 53 | */ |
||
| 54 | abstract protected function init(); |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @return bool |
||
| 58 | */ |
||
| 59 | protected function hasRoute() |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @return string |
||
| 66 | */ |
||
| 67 | protected function getPath() |
||
| 71 | |||
| 72 | /** |
||
| 73 | * @param string|null $path |
||
| 74 | * @return $this |
||
| 75 | */ |
||
| 76 | public function setPath($path = null) |
||
| 81 | |||
| 82 | /** |
||
| 83 | * @return bool |
||
| 84 | */ |
||
| 85 | protected function hasSpec() |
||
| 89 | |||
| 90 | /** |
||
| 91 | * @return string |
||
| 92 | */ |
||
| 93 | protected function getSpec() |
||
| 97 | |||
| 98 | /** |
||
| 99 | * @param string|null $spec |
||
| 100 | * @return $this |
||
| 101 | */ |
||
| 102 | protected function setSpec($spec = null) |
||
| 107 | } |
||
| 108 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: