| 1 | <?php |
||
| 7 | trait Translatable |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * {@inheritdoc} |
||
| 11 | */ |
||
| 12 | public static function bootTranslatable() |
||
| 16 | |||
| 17 | /** |
||
| 18 | * Return next fresh translation ID. |
||
| 19 | * |
||
| 20 | * @return int |
||
| 21 | */ |
||
| 22 | public static function freshTranslationId() |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Return translation ID value. |
||
| 38 | * |
||
| 39 | * @return int |
||
| 40 | */ |
||
| 41 | public function translationId() |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Define translation ID field name. |
||
| 48 | * |
||
| 49 | * @return string |
||
| 50 | */ |
||
| 51 | public function translationIdField() |
||
| 55 | } |
||
| 56 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idableprovides a methodequalsIdthat in turn relies on the methodgetId(). If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()as an abstract method to the trait will make sure it is available.