IsModelSearchable::isModelSearchable()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 9
ccs 5
cts 5
cp 1
crap 2
rs 10
c 0
b 0
f 0
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