Completed
Pull Request — master (#223)
by Axel
04:10
created

SearchesExact::__invoke()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
cc 3
nc 3
nop 4
1
<?php
2
3
namespace Spatie\QueryBuilder\Searches;
4
5
use Illuminate\Database\Eloquent\Builder;
6
7
class SearchesExact extends SearchesBase
8
{
9
    public function __invoke(Builder $query, $value, string $property, ?string $modifier = null) : Builder
10
    {
11
        if ($this->isRelationProperty($query, $property)) {
12
            return $this->withRelationConstraint($query, $value, $property);
13
        }
14
15
        if (is_array($value)) {
16
            return $query->orWhereIn($property, $value);
17
        }
18
19
        return $query->orWhere($property, '=', $value);
20
    }
21
}
22