| Conditions | 4 |
| Paths | 4 |
| Total Lines | 13 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 4 |
| Changes | 7 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 28 | 4 | public function localized($language = null, $abridge = true) |
|
| 29 | { |
||
| 30 | 4 | $language = $language ?: Yii::$app->language; |
|
| 31 | |||
| 32 | 4 | if (!isset($this->with['translations'])) { |
|
| 33 | 4 | $this->with(['translation' => function ($query) use ($language, $abridge) { |
|
|
|
|||
| 34 | /** @var ActiveQuery $query */ |
||
| 35 | 3 | $query->where([$this->languageField => $abridge ? substr($language, 0, 2) : $language]); |
|
| 36 | 4 | }]); |
|
| 37 | 4 | } |
|
| 38 | |||
| 39 | 4 | return $this; |
|
| 40 | } |
||
| 41 | |||
| 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.