Completed
Pull Request — master (#43)
by Rick
19:13 queued 19:13
created

FilterRule   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 79
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 7
Bugs 0 Features 1
Metric Value
wmc 6
c 7
b 0
f 1
lcom 1
cbo 0
dl 0
loc 79
ccs 15
cts 15
cp 1
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A setEncodingFormat() 0 4 1
A setEmpty() 0 5 1
A isEmpty() 0 4 1
A setFilterData() 0 4 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 9
    public function isEmpty()
59
    {
60 9
        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 163
    }
70
71
    /**
72
     * @return array|null
73
     */
74 5
    public function getFilterData()
75
    {
76 5
        return $this->filterData;
77
    }
78
79
    /**
80
     * @return bool
81
     */
82 14
    public function allowedNotSet()
83
    {
84 14
        return $this->allowNotSet;
85
    }
86
87
    /**
88
     * @param mixed $value
89
     * @return mixed
90
     */
91
    abstract public function filter($value);
92
}
93