Test Failed
Pull Request — master (#12)
by
unknown
06:34
created

PatternReplacer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 9
dl 0
loc 37
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A replace() 0 10 1
1
<?php
2
/**
3
 * Copyright MediaCT. All rights reserved.
4
 * https://www.mediact.nl
5
 */
6
7
namespace Mediact\DataContainer;
8
9
class PatternReplacer implements PatternReplacerInterface
10
{
11
    use ReplaceByPatternTrait;
12
13
    /** @var string */
14
    private $separator;
15
16
    /**
17
     * Constructor.
18
     *
19
     * @param string $separator
20
     */
21
    public function __construct(
22
        string $separator = DataContainerInterface::SEPARATOR
23
    ) {
24
        $this->separator = $separator;
25
    }
26
27
    /**
28
     * Get a replacement path for a matched path.
29
     *
30
     * @param string $match
31
     * @param string $pattern
32
     * @param string $replacement
33
     *
34
     * @return string
35
     */
36
    public function replace(
37
        string $match,
38
        string $pattern,
39
        string $replacement
40
    ): string {
41
        return $this->replaceByPattern(
42
            $pattern,
43
            $match,
44
            $replacement,
45
            $this->separator
46
        );
47
    }
48
}
49