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

Column::jsonSerialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 8
c 0
b 0
f 0
ccs 6
cts 6
cp 1
rs 10
cc 1
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
 * Column parameters as part of DataTables request.
18
 *
19
 * @see https://www.datatables.net/manual/server-side
20
 *
21
 * @property string $data       Column's data source.
22
 * @property string $name       Column's name.
23
 * @property bool   $searchable Flag to indicate if this column is searchable or not.
24
 * @property bool   $orderable  Flag to indicate if this column is orderable or not.
25
 * @property Search $search     Search value to apply to this specific column.
26
 */
27
class Column extends ValueObject implements \JsonSerializable
28
{
29
    protected $data;
30
    protected $name;
31
    protected $searchable;
32
    protected $orderable;
33
    protected $search;
34
35
    /**
36
     * Initializing constructor.
37
     *
38
     * @param string $data
39
     * @param string $name
40
     * @param bool   $searchable
41
     * @param bool   $orderable
42
     * @param Search $search
43
     */
44 1
    public function __construct(string $data, string $name, bool $searchable, bool $orderable, Search $search)
45
    {
46 1
        $this->data       = $data;
47 1
        $this->name       = $name;
48 1
        $this->searchable = $searchable;
49 1
        $this->orderable  = $orderable;
50 1
        $this->search     = $search;
51 1
    }
52
53
    /**
54
     * {@inheritdoc}
55
     *
56
     * @return array
57
     */
58 1
    public function jsonSerialize()
59
    {
60
        return [
61 1
            'data'       => $this->data,
62 1
            'name'       => $this->name,
63 1
            'searchable' => $this->searchable,
64 1
            'orderable'  => $this->orderable,
65 1
            'search'     => $this->search->jsonSerialize(),
66
        ];
67
    }
68
}
69