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

Transformation::getReplacement()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 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