Callback   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A filter() 0 4 1
1
<?php
2
/**
3
 * Particle.
4
 *
5
 * @link      http://github.com/particle-php for the canonical source repository
6
 * @copyright Copyright (c) 2005-2016 Particle (http://particle-php.com)
7
 * @license   https://github.com/particle-php/Filter/blob/master/LICENSE New BSD License
8
 */
9
namespace Particle\Filter\FilterRule;
10
11
use Particle\Filter\FilterRule;
12
13
/**
14
 * Class Callback
15
 *
16
 * @package Particle\Filter\FilterRule
17
 */
18
class Callback extends FilterRule
19
{
20
    /**
21
     * @var callable
22
     */
23
    protected $callable;
24
25
    /**
26
     * Set callable closure
27
     *
28
     * @param callable $callable
29
     * @param bool $allowNotSet
30
     */
31 6
    public function __construct(callable $callable, $allowNotSet = false)
32
    {
33 6
        $this->callable = $callable;
34 6
        $this->allowNotSet = $allowNotSet;
35 6
    }
36
37
    /**
38
     * Execute the callable and provide a callback for the given value
39
     *
40
     * @param mixed $value
41
     * @return mixed
42
     */
43 5
    public function filter($value)
44
    {
45 5
        return call_user_func($this->callable, $value, $this->getFilterData());
46
    }
47
}
48