Issues (25)

src/WithIndexes.php (2 issues)

Labels
Severity
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
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
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