Completed
Push — master ( f05f74...746c7e )
by Rick
14:39 queued 25s
created

FilterRule::isNotEmpty()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * Particle.
4
 *
5
 * @link      http://github.com/particle-php for the canonical source repository
6
 * @copyright Copyright (c) 2005-2015 Particle (http://particle-php.com)
7
 * @license   https://github.com/particle-php/Filter/blob/master/LICENSE New BSD License
8
 */
9
namespace Particle\Filter;
10
11
/**
12
 * @package Particle\Filter
13
 */
14
abstract class FilterRule
15
{
16
    /**
17
     * @var string|null
18
     */
19
    protected $encodingFormat;
20
21
    /**
22
     * @var bool
23
     */
24
    protected $allowNotSet = false;
25
26
    /**
27
     * @var bool
28
     */
29
    protected $isEmpty = false;
30
31
    /**
32
     * @var array|null
33
     */
34
    protected $filterData;
35
36
    /**
37
     * @param string|null $encodingFormat
38
     */
39 163
    public function setEncodingFormat($encodingFormat)
40
    {
41 163
        $this->encodingFormat = $encodingFormat;
42 163
    }
43
44
    /**
45
     * Set the value to empty
46
     *
47
     * @return null
48
     */
49 6
    protected function setEmpty()
50
    {
51 6
        $this->isEmpty = true;
52 6
        return null;
53
    }
54
55
    /**
56
     * @return bool
57
     */
58 160
    public function isNotEmpty()
59
    {
60 160
        return !$this->isEmpty;
61
    }
62
63
    /**
64
     * @param array|null $filterData
65
     */
66 163
    public function setFilterData($filterData)
67
    {
68 163
        $this->filterData = $filterData;
69
70
        // Make sure that the value is not empty by default
71 163
        $this->isEmpty = false;
72 163
    }
73
74
    /**
75
     * @return array|null
76
     */
77 5
    public function getFilterData()
78
    {
79 5
        return $this->filterData;
80
    }
81
82
    /**
83
     * @return bool
84
     */
85 14
    public function allowedNotSet()
86
    {
87 14
        return $this->allowNotSet;
88
    }
89
90
    /**
91
     * @param mixed $value
92
     * @return mixed
93
     */
94
    abstract public function filter($value);
95
}
96