SearchableCardFilter   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 0
loc 10
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 7 1
1
<?php
2
/*
3
 * This file is part of the flash.dev package.
4
 *
5
 * (c) Mohamed Alsharaf <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Moo\FlashCard\Api;
12
13
use Illuminate\Database\Eloquent\Builder;
14
use Spatie\QueryBuilder\Filters\Filter;
15
16
/**
17
 * Class SearchableCardFilter provide searchable custom filter for spatie query builder module
18
 */
19
class SearchableCardFilter implements Filter
20
{
21 3
    public function __invoke(Builder $query, $value, string $property): Builder
22
    {
23
        // Filter a query by search for LIKE title or content
24
        return $query->where(function (Builder $query) use ($value) {
25 3
            $query->search($value);
26 3
        });
27
    }
28
}
29