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

LikeBuilder   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

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

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A begins() 0 4 1
A notBegins() 0 4 1
A contains() 0 4 1
A notContains() 0 4 1
A ends() 0 4 1
A notEnds() 0 4 1
A like() 0 4 1
A notLike() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Latitude\QueryBuilder\Builder;
5
6
use Latitude\QueryBuilder\CriteriaInterface;
7
use Latitude\QueryBuilder\StatementInterface;
8
use Latitude\QueryBuilder\Partial\{
9
    LikeBegins,
10
    LikeContains,
11
    LikeEnds
12
};
13
14
use function Latitude\QueryBuilder\criteria;
15
16
class LikeBuilder
17
{
18
    /** @var StatementInterface */
19
    private $statement;
20
21 4
    public function __construct(StatementInterface $statement)
22
    {
23 4
        $this->statement = $statement;
24 4
    }
25
26 1
    public function begins(string $value): CriteriaInterface
27
    {
28 1
        return $this->like(new LikeBegins($value));
29
    }
30
31 1
    public function notBegins(string $value): CriteriaInterface
32
    {
33 1
        return $this->notLike(new LikeBegins($value));
34
    }
35
36 2
    public function contains(string $value): CriteriaInterface
37
    {
38 2
        return $this->like(new LikeContains($value));
39
    }
40
41 1
    public function notContains(string $value): CriteriaInterface
42
    {
43 1
        return $this->notLike(new LikeContains($value));
44
    }
45
46 1
    public function ends(string $value): CriteriaInterface
47
    {
48 1
        return $this->like(new LikeEnds($value));
49
    }
50
51 1
    public function notEnds(string $value): CriteriaInterface
52
    {
53 1
        return $this->notLike(new LikeEnds($value));
54
    }
55
56 4
    protected function like(StatementInterface $value): CriteriaInterface
57
    {
58 4
        return criteria('%s LIKE %s', $this->statement, $value);
59
    }
60
61 3
    protected function notLike(StatementInterface $value): CriteriaInterface
62
    {
63 3
        return criteria('%s NOT LIKE %s', $this->statement, $value);
64
    }
65
}
66