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

FilterRule   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 82
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 9
Bugs 0 Features 1
Metric Value
wmc 6
c 9
b 0
f 1
lcom 1
cbo 0
dl 0
loc 82
ccs 16
cts 16
cp 1
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A setEncodingFormat() 0 4 1
A setEmpty() 0 5 1
A isNotEmpty() 0 4 1
A setFilterData() 0 7 1
A getFilterData() 0 4 1
A allowedNotSet() 0 4 1
filter() 0 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