Completed
Push — master ( b4b898...f81b53 )
by Woody
11s
created

src/Query/Capability/HasWhere.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
declare(strict_types=1);
3
4
namespace Latitude\QueryBuilder\Query\Capability;
5
6
use Latitude\QueryBuilder\CriteriaInterface;
7
use Latitude\QueryBuilder\ExpressionInterface;
8
9
trait HasWhere
10
{
11
    /** @var CriteriaInterface */
12
    protected $where;
13
14 5
    public function where(CriteriaInterface $criteria): self
15
    {
16 5
        $this->where = $criteria;
17 5
        return $this;
18
    }
19
20 1 View Code Duplication
    public function andWhere(CriteriaInterface $criteria): self
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
21
    {
22 1
        if ($this->where === null) {
23 1
            return $this->where($criteria);
24
        }
25
26 1
        $this->where = $this->where->and($criteria);
27 1
        return $this;
28
    }
29
30 1 View Code Duplication
    public function orWhere(CriteriaInterface $criteria): self
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
31
    {
32 1
        if ($this->where === null) {
33 1
            return $this->where($criteria);
34
        }
35
36 1
        $this->where = $this->where->or($criteria);
37 1
        return $this;
38
    }
39
40 29
    protected function applyWhere(ExpressionInterface $query): ExpressionInterface
41
    {
42 29
        return $this->where ? $query->append('WHERE %s', $this->where) : $query;
43
    }
44
}
45