Completed
Push — master ( d5342a...a39283 )
by WEBEWEB
02:05
created

DataTablesOrder::parse()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 28

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 28
rs 9.472
c 0
b 0
f 0
cc 4
nc 4
nop 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A DataTablesOrder::setDir() 0 7 2
1
<?php
2
3
/**
4
 * This file is part of the jquery-datatables-bundle package.
5
 *
6
 * (c) 2018 WEBEWEB
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WBW\Bundle\JQuery\DataTablesBundle\API;
13
14
use WBW\Bundle\JQuery\DataTablesBundle\Helper\DataTablesOrderHelper;
15
16
/**
17
 * DataTables order.
18
 *
19
 * @author webeweb <https://github.com/webeweb/>
20
 * @package WBW\Bundle\JQuery\DataTablesBundle\API
21
 */
22
class DataTablesOrder implements DataTablesOrderInterface {
23
24
    /**
25
     * Column.
26
     *
27
     * @var int
28
     */
29
    private $column;
30
31
    /**
32
     * Dir.
33
     *
34
     * @var string
35
     */
36
    private $dir;
37
38
    /**
39
     * Constructor.
40
     */
41
    public function __construct() {
42
        // NOTHING TO DO
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function getColumn() {
49
        return $this->column;
50
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55
    public function getDir() {
56
        return $this->dir;
57
    }
58
59
    /**
60
     * Set the column.
61
     *
62
     * @param int $column The column.
63
     * @return DataTablesOrderInterface Returns this order.
64
     */
65
    public function setColumn($column) {
66
        $this->column = (0 <= $column ? $column : null);
67
        return $this;
68
    }
69
70
    /**
71
     * Set the dir.
72
     *
73
     * @param string $dir The dir.
74
     * @return DataTablesOrderInterface Returns this order.
75
     */
76
    public function setDir($dir) {
77
        if (false === in_array($dir, DataTablesOrderHelper::dtDirs())) {
78
            $dir = self::DATATABLES_DIR_ASC;
79
        }
80
        $this->dir = strtoupper($dir);
81
        return $this;
82
    }
83
84
}
85