| 1 | <?php | ||
| 13 | trait MultilingualTrait | ||
| 14 | { | ||
| 15 | /** | ||
| 16 | * @var string the name of the lang field of the translation table. Default to 'language'. | ||
| 17 | */ | ||
| 18 | public $languageField = 'language'; | ||
| 19 | |||
| 20 | /** | ||
| 21 | * Scope for querying by languages | ||
| 22 | * | ||
| 23 | * @param string $language | ||
| 24 | * @param bool $abridge | ||
| 25 | * | ||
| 26 | * @return $this | ||
| 27 | */ | ||
| 28 | 4 | public function localized($language = null, $abridge = true) | |
| 41 | |||
| 42 | /** | ||
| 43 | * Scope for querying by all languages | ||
| 44 | * @return $this | ||
| 45 | */ | ||
| 46 | 6 | public function multilingual() | |
| 54 | } | ||
| 55 | 
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.