OrderBy   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 77
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 77
c 1
b 0
f 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getColumn() 0 4 1
A setColumn() 0 6 1
A getDirection() 0 4 1
A setDirection() 0 11 2
1
<?php
2
/**
3
 * Author: Nil Portugués Calderó <[email protected]>
4
 * Date: 6/3/14
5
 * Time: 12:07 AM.
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace NilPortugues\Sql\QueryBuilder\Syntax;
12
13
/**
14
 * Class OrderBy.
15
 */
16
class OrderBy
17
{
18
    const ASC = 'ASC';
19
    const DESC = 'DESC';
20
21
    /**
22
     * @var Column
23
     */
24
    protected $column;
25
26
    /**
27
     * @var string
28
     */
29
    protected $direction;
30
31
    /**
32
     * @var bool
33
     */
34
    protected $useAlias;
35
36
    /**
37
     * @param Column $column
38
     * @param string $direction
39
     */
40
    public function __construct(Column $column, $direction)
41
    {
42
        $this->setColumn($column);
43
        $this->setDirection($direction);
44
    }
45
46
    /**
47
     * @return Column
48
     */
49
    public function getColumn()
50
    {
51
        return $this->column;
52
    }
53
54
    /**
55
     * @param Column $column
56
     *
57
     * @return $this
58
     */
59
    public function setColumn($column)
60
    {
61
        $this->column = $column;
62
63
        return $this;
64
    }
65
66
    /**
67
     * @return string
68
     */
69
    public function getDirection()
70
    {
71
        return $this->direction;
72
    }
73
74
    /**
75
     * @param string $direction
76
     *
77
     * @throws \InvalidArgumentException
78
     *
79
     * @return $this
80
     */
81
    public function setDirection($direction)
82
    {
83
        if (!in_array($direction, array(self::ASC, self::DESC))) {
84
            throw new \InvalidArgumentException(
85
                "Specified direction '$direction' is not allowed. Only ASC or DESC are allowed."
86
            );
87
        }
88
        $this->direction = $direction;
89
90
        return $this;
91
    }
92
}
93