Completed
Push — master ( 7a35bc...7eff79 )
by Krzysztof
05:49 queued 02:58
created

OrderByCriteria::setOrderBy()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
ccs 3
cts 3
cp 1
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace KGzocha\Searcher\Criteria;
4
5
/**
6
 * @author Krzysztof Gzocha <[email protected]>
7
 */
8
class OrderByCriteria implements OrderByCriteriaInterface
9
{
10
    /**
11
     * @var null|string
12
     */
13
    private $orderBy;
14
15
    /**
16
     * @param null|string $orderBy
17
     */
18 10
    public function __construct($orderBy = null)
19
    {
20 10
        $this->orderBy = $orderBy;
21 10
    }
22
23
    /**
24
     * @return null|string
25
     */
26 3
    public function getOrderBy()
27
    {
28 3
        return $this->orderBy;
29
    }
30
31
    /**
32
     * @param null|string $orderBy
33
     */
34 6
    public function setOrderBy($orderBy)
35
    {
36 6
        $this->orderBy = $orderBy;
37 6
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42 4
    public function shouldBeApplied()
43
    {
44 4
        return $this->orderBy != null;
0 ignored issues
show
Bug introduced by
It seems like you are loosely comparing $this->orderBy of type null|string against null; this is ambiguous if the string can be empty. Consider using a strict comparison !== instead.
Loading history...
45
    }
46
}
47