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

PatternReplacer::replace()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 10
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
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