Completed
Push — master ( 37f225...776e9c )
by Artem
04:27
created

Order::jsonSerialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

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 7
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
crap 1
1
<?php
2
3
//----------------------------------------------------------------------
4
//
5
//  Copyright (C) 2016 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-read   int    $column Column to which ordering should be applied.
22
 * @property-read   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 4
    public function __construct(int $column, string $dir)
39
    {
40 4
        $this->column = $column;
41 4
        $this->dir    = $dir;
42 4
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47 2
    public function jsonSerialize()
48
    {
49
        return [
50 2
            'column' => $this->column,
51 2
            'dir'    => $this->dir,
52
        ];
53
    }
54
}
55