Conditions | 4 |
Paths | 4 |
Total Lines | 22 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 4.016 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | 27 | public function isTranslatable($columns = null) |
|
8 | { |
||
9 | // Model must have the trait |
||
10 | 27 | if (!classHasTrait($this, 'A17\Twill\Models\Behaviors\HasTranslation')) { |
|
11 | 1 | return false; |
|
12 | } |
||
13 | |||
14 | // Model must have the translatedAttributes property |
||
15 | 26 | if (!property_exists($this, 'translatedAttributes')) { |
|
16 | return false; |
||
17 | } |
||
18 | |||
19 | // If it's a check on certain columns |
||
20 | // They must be present in the translatedAttributes |
||
21 | 26 | if (filled($columns)) { |
|
22 | 5 | return collect($this->translatedAttributes) |
|
23 | 5 | ->intersect(collect($columns)) |
|
24 | 5 | ->isNotEmpty(); |
|
25 | } |
||
26 | |||
27 | // The translatedAttributes property must be filled |
||
28 | 26 | return collect($this->translatedAttributes)->isNotEmpty(); |
|
29 | } |
||
31 |