Failed Conditions
Pull Request — master (#97)
by Jonathan
03:14
created

Transformation   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 27
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A replace() 0 3 1
A getPattern() 0 3 1
A getReplacement() 0 3 1
A __construct() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Inflector\Rules;
6
7
use function preg_replace;
8
9
final class Transformation
10
{
11
    /** @var Pattern */
12
    private $pattern;
13
14
    /** @var string */
15
    private $replacement;
16
17 530
    public function __construct(Pattern $pattern, string $replacement)
18
    {
19 530
        $this->pattern     = $pattern;
20 530
        $this->replacement = $replacement;
21 530
    }
22
23 180
    public function getPattern() : Pattern
24
    {
25 180
        return $this->pattern;
26
    }
27
28 1
    public function getReplacement() : string
29
    {
30 1
        return $this->replacement;
31
    }
32
33 177
    public function replace(string $word) : string
34
    {
35 177
        return preg_replace($this->pattern->getRegex(), $this->replacement, $word);
36
    }
37
}
38