| 1 | <?php |
||
| 14 | trait Activatable |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * @return bool |
||
| 18 | */ |
||
| 19 | public function isActive(): bool |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @param bool|callable $active |
||
| 26 | * |
||
| 27 | * @return $this |
||
| 28 | */ |
||
| 29 | public function setActive($active = true) |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @return $this |
||
| 44 | */ |
||
| 45 | public function setInactive() |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @return string|null |
||
| 54 | */ |
||
| 55 | public function url() |
||
| 59 | |||
| 60 | /** |
||
| 61 | * @return bool |
||
| 62 | */ |
||
| 63 | public function hasUrl(): bool |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @param string|null $url |
||
| 70 | * |
||
| 71 | * @return $this |
||
| 72 | */ |
||
| 73 | public function setUrl($url) |
||
| 79 | |||
| 80 | /** |
||
| 81 | * @param string $url |
||
| 82 | * @param string $root |
||
| 83 | * |
||
| 84 | * @return $this |
||
| 85 | */ |
||
| 86 | public function determineActiveForUrl(string $url, string $root = '/') |
||
| 96 | } |
||
| 97 |
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: