WithIndexes   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Importance

Changes 4
Bugs 0 Features 1
Metric Value
wmc 2
eloc 4
c 4
b 0
f 1
dl 0
loc 11
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A search() 0 7 2
1
<?php
2
/**
3
 * Created by enea dhack - 13/06/2020 13:01.
4
 */
5
6
namespace Vaened\Searcher;
7
8
trait WithIndexes
9
{
10
    abstract protected function getIndexProvider(): Indexable;
11
12
    public function search(string $index, ?string $q): self
13
    {
14
        if ($q != null) {
0 ignored issues
show
Bug introduced by
It seems like you are loosely comparing $q of type null|string against null; this is ambiguous if the string can be empty. Consider using a strict comparison !== instead.
Loading history...
15
            $this->apply($this->getIndexProvider()->getConstraint($index, $q));
0 ignored issues
show
Bug introduced by
It seems like apply() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

15
            $this->/** @scrutinizer ignore-call */ 
16
                   apply($this->getIndexProvider()->getConstraint($index, $q));
Loading history...
16
        }
17
18
        return $this;
19
    }
20
}
21