| Conditions | 2 |
| Paths | 2 |
| Total Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 22 | public static function freshTranslationId() |
||
| 23 | { |
||
| 24 | $instance = new static; |
||
| 25 | $translationIdField = $instance->translationIdField(); |
||
| 26 | |||
| 27 | $lastTranslation = static::query() |
||
| 28 | ->withoutGlobalScope(TranslatableScope::class) |
||
| 29 | ->select($instance->getTable() . '.'. $translationIdField) |
||
|
|
|||
| 30 | ->orderBy($translationIdField, 'desc') |
||
| 31 | ->first(); |
||
| 32 | |||
| 33 | return ! empty($lastTranslation) ? ($lastTranslation->getAttribute($translationIdField) + 1) : 1; |
||
| 34 | } |
||
| 35 | |||
| 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.