Completed
Push — master ( aef7f8...916348 )
by WEBEWEB
01:35
created

DataTablesOrder   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 0
loc 62
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getColumn() 0 3 1
A getDir() 0 3 1
A setColumn() 0 4 2
A 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\Model;
13
14
use WBW\Bundle\JQuery\DataTablesBundle\API\DataTablesOrderInterface;
15
16
/**
17
 * DataTables order.
18
 *
19
 * @author webeweb <https://github.com/webeweb/>
20
 * @package WBW\Bundle\JQuery\DataTablesBundle\Model
21
 */
22
class DataTablesOrder implements DataTablesOrderInterface {
23
24
    /**
25
     * Column.
26
     *
27
     * @var int|null
28
     */
29
    private $column;
30
31
    /**
32
     * Dir.
33
     *
34
     * @var string|null
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(): ?int {
49
        return $this->column;
50
    }
51
52
    /**
53
     * {@inheritDoc}
54
     */
55
    public function getDir(): ?string {
56
        return $this->dir;
57
    }
58
59
    /**
60
     * Set the column.
61
     *
62
     * @param int|null $column The column.
63
     * @return DataTablesOrderInterface Returns this order.
64
     */
65
    public function setColumn(?int $column): DataTablesOrderInterface {
66
        $this->column = (0 <= $column ? $column : null);
67
        return $this;
68
    }
69
70
    /**
71
     * Set the dir.
72
     *
73
     * @param string|null $dir The dir.
74
     * @return DataTablesOrderInterface Returns this order.
75
     */
76
    public function setDir(?string $dir): DataTablesOrderInterface {
77
        if (false === in_array($dir, DataTablesEnumerator::enumDirs())) {
78
            $dir = self::DATATABLES_DIR_ASC;
79
        }
80
        $this->dir = strtoupper($dir);
81
        return $this;
82
    }
83
}
84