Check   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 54
rs 10
c 0
b 0
f 0
ccs 12
cts 12
cp 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getFormControl() 0 6 1
A __getCondition() 0 8 2
A formatValue() 0 4 1
A changeValue() 0 6 2
1
<?php
2
3
/**
4
 * This file is part of the Grido (https://github.com/o5/grido)
5
 *
6
 * Copyright (c) 2011 Petr Bugyík (http://petr.bugyik.cz)
7
 *
8
 * For the full copyright and license information, please view
9
 * the file LICENSE.md that was distributed with this source code.
10
 */
11
12
namespace Grido\Components\Filters;
13
14
/**
15
 * Check box filter.
16
 *
17
 * @package     Grido
18
 * @subpackage  Components\Filters
19
 * @author      Petr Bugyík
20
 */
21
class Check extends Filter
22 1
{
23
    /* representation TRUE in URI */
24
    const TRUE = '✓';
25
26
    /** @var string */
27
    protected $condition = 'IS NOT NULL';
28 1
29
    /**
30
     * @return \Nette\Forms\Controls\Checkbox
31
     */
32
    protected function getFormControl()
33
    {
34 1
        $control = new \Nette\Forms\Controls\Checkbox($this->label);
35 1
        $control->getControlPrototype()->class[] = 'checkbox';
36 1
        return $control;
37
    }
38
39
    /**
40
     * @param string $value
41
     * @return Condition|bool
42
     * @internal
43
     */
44
    public function __getCondition($value)
45
    {
46
        $value = $value == self::TRUE
47 1
            ? TRUE
48 1
            : FALSE;
49
50 1
        return parent::__getCondition($value);
51
    }
52
53
    /**
54
     * @param bool $value
55
     * @return NULL
56
     * @internal
57
     */
58
    public function formatValue($value)
59
    {
60 1
        return NULL;
61
    }
62
63
    /**
64
     * @param bool $value
65
     * @return string
66
     * @internal
67
     */
68
    public function changeValue($value)
69
    {
70 1
        return (bool) $value === TRUE
71 1
            ? self::TRUE
72 1
            : $value;
73
    }
74
}
75