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

Search   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
eloc 8
c 2
b 0
f 0
dl 0
loc 27
ccs 7
cts 7
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A jsonSerialize() 0 5 1
A __construct() 0 4 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
 * Search parameters as part of DataTables request.
18
 *
19
 * @see https://www.datatables.net/manual/server-side
20
 *
21
 * @property string $value Search value.
22
 * @property bool   $regex Whether the search value should be treated as a regular expression for advanced searching.
23
 */
24
class Search extends ValueObject implements \JsonSerializable
25
{
26
    protected $value;
27
    protected $regex;
28
29
    /**
30
     * Initializing constructor.
31
     *
32
     * @param null|string $value
33
     * @param bool        $regex
34
     */
35 1
    public function __construct(string $value = null, bool $regex = false)
36
    {
37 1
        $this->value = $value;
38 1
        $this->regex = $regex;
39 1
    }
40
41
    /**
42
     * {@inheritdoc}
43
     *
44
     * @return array
45
     */
46 1
    public function jsonSerialize()
47
    {
48
        return [
49 1
            'value' => $this->value,
50 1
            'regex' => $this->regex,
51
        ];
52
    }
53
}
54