OrderByCriteria   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 39
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getOrderBy() 0 4 1
A setOrderBy() 0 4 1
A shouldBeApplied() 0 4 2
1
<?php
2
declare(strict_types=1);
3
4
namespace KGzocha\Searcher\Criteria;
5
6
/**
7
 * @author Krzysztof Gzocha <[email protected]>
8
 */
9
class OrderByCriteria implements OrderByCriteriaInterface
10
{
11
    /**
12
     * @var null|string
13
     */
14
    private $orderBy;
15
16
    /**
17
     * @param null|string $orderBy
18
     */
19 14
    public function __construct(string $orderBy = null)
20
    {
21 14
        $this->orderBy = $orderBy;
22 14
    }
23
24
    /**
25
     * @return null|string
26
     */
27 5
    public function getOrderBy()
28
    {
29 5
        return $this->orderBy;
30
    }
31
32
    /**
33
     * @param null|string $orderBy
34
     */
35 10
    public function setOrderBy(string $orderBy = null)
36
    {
37 10
        $this->orderBy = $orderBy;
38 10
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43 8
    public function shouldBeApplied(): bool
44
    {
45 8
        return $this->orderBy !== null && !empty($this->orderBy);
46
    }
47
}
48