Transformation::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Inflector\Rules;
6
7
use Doctrine\Inflector\WordInflector;
8
use function preg_replace;
9
10
final class Transformation implements WordInflector
11
{
12
    /** @var Pattern */
13
    private $pattern;
14
15
    /** @var string */
16
    private $replacement;
17
18 1109
    public function __construct(Pattern $pattern, string $replacement)
19
    {
20 1109
        $this->pattern     = $pattern;
21 1109
        $this->replacement = $replacement;
22 1109
    }
23
24 490
    public function getPattern() : Pattern
25
    {
26 490
        return $this->pattern;
27
    }
28
29 1
    public function getReplacement() : string
30
    {
31 1
        return $this->replacement;
32
    }
33
34 485
    public function inflect(string $word) : string
35
    {
36 485
        return (string) preg_replace($this->pattern->getRegex(), $this->replacement, $word);
37
    }
38
}
39