Passed
Push — master ( e1e679...09e224 )
by Quentin
10:29
created

IsTranslatable   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 90%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 24
ccs 9
cts 10
cp 0.9
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A isTranslatable() 0 22 4
1
<?php
2
3
namespace A17\Twill\Models\Behaviors;
4
5
trait IsTranslatable
6
{
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
    }
30
}
31