Replace   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

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 Replace
15
 *
16
 * @package Particle\Filter\FilterRule
17
 */
18
class Replace extends FilterRule
19
{
20
    /**
21
     * @var mixed
22
     */
23
    protected $search;
24
25
    /**
26
     * @var mixed
27
     */
28
    protected $replace;
29
30
    /**
31
     * Set required params for replacement
32
     *
33
     * @param $search
34
     * @param $replace
35
     */
36 5
    public function __construct($search, $replace)
37
    {
38 5
        $this->search = $search;
39 5
        $this->replace = $replace;
40 5
    }
41
42
    /**
43
     * Replace matched for a replacement in the value
44
     *
45
     * @param mixed $value
46
     * @return string
47
     */
48 5
    public function filter($value)
49
    {
50 5
        return str_replace($this->search, $this->replace, $value);
51
    }
52
}
53