PatternReplacer   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 9
c 1
b 0
f 0
dl 0
loc 37
ccs 9
cts 9
cp 1
rs 10

2 Methods

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