Passed
Push — master ( a7f0ec...c2460d )
by Artem
02:49
created

Order::__construct()   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
eloc 2
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
//----------------------------------------------------------------------
4
//
5
//  Copyright (C) 2015-2019 Artem Rodygin
6
//
7
//  This file is part of DataTables Symfony bundle.
8
//
9
//  You should have received a copy of the MIT License along with
10
//  the bundle. If not, see <http://opensource.org/licenses/MIT>.
11
//
12
//----------------------------------------------------------------------
13
14
namespace DataTables;
15
16
/**
17
 * Ordering parameters as part of DataTables request.
18
 *
19
 * @see https://www.datatables.net/manual/server-side
20
 *
21
 * @property int    $column Column to which ordering should be applied.
22
 * @property string $dir    Ordering direction for this column.
23
 */
24
class Order extends ValueObject implements \JsonSerializable
25
{
26
    const ASC  = 'asc';
27
    const DESC = 'desc';
28
29
    protected $column;
30
    protected $dir;
31
32
    /**
33
     * Initializing constructor.
34
     *
35
     * @param int    $column
36
     * @param string $dir
37
     */
38 1
    public function __construct(int $column, string $dir)
39
    {
40 1
        $this->column = $column;
41 1
        $this->dir    = $dir;
42 1
    }
43
44
    /**
45
     * {@inheritdoc}
46
     *
47
     * @return array
48
     */
49 1
    public function jsonSerialize()
50
    {
51
        return [
52 1
            'column' => $this->column,
53 1
            'dir'    => $this->dir,
54
        ];
55
    }
56
}
57