| 1 | <?php |
||
| 11 | trait Validatable |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * Boot the trait. |
||
| 15 | */ |
||
| 16 | protected static function bootValidatable() |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Validates current attributes against rules |
||
| 31 | * |
||
| 32 | * @return bool |
||
| 33 | * @throws \DomainException |
||
| 34 | */ |
||
| 35 | public function validate() |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Get instance of validator |
||
| 48 | * |
||
| 49 | * @return \Illuminate\Validation\Validator |
||
| 50 | */ |
||
| 51 | public function getValidator(): \Illuminate\Validation\Validator |
||
| 55 | |||
| 56 | /** |
||
| 57 | * Required method that provide collection or rules |
||
| 58 | * |
||
| 59 | * @return array |
||
| 60 | */ |
||
| 61 | abstract protected function getRules(): array; |
||
| 62 | } |
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: