IsModelSearchable   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 19
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A isModelSearchable() 0 9 2
1
<?php
2
namespace Triadev\Leopard\Business\Helper;
3
4
use Illuminate\Database\Eloquent\Model;
5
use Triadev\Leopard\Searchable;
6
7
trait IsModelSearchable
8
{
9
    /**
10
     * Is model searchable
11
     *
12
     * @param Model $model
13
     * @return true
14
     *
15
     * @throws \InvalidArgumentException
16
     */
17 18
    public function isModelSearchable(Model $model) : bool
18
    {
19 18
        $traits = class_uses_recursive(get_class($model));
20
        
21 18
        if (!isset($traits[Searchable::class])) {
22 2
            throw new \InvalidArgumentException(get_class($model).' does not use the searchable trait.');
23
        }
24
        
25 16
        return true;
26
    }
27
}
28