Passed
Pull Request — master (#97)
by Jonathan
09:17
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 getPattern() 0 3 1
A getReplacement() 0 3 1
A inflect() 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 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 764
    public function __construct(Pattern $pattern, string $replacement)
19
    {
20 764
        $this->pattern     = $pattern;
21 764
        $this->replacement = $replacement;
22 764
    }
23
24 343
    public function getPattern() : Pattern
25
    {
26 343
        return $this->pattern;
27
    }
28
29 1
    public function getReplacement() : string
30
    {
31 1
        return $this->replacement;
32
    }
33
34 341
    public function inflect(string $word) : string
35
    {
36 341
        return preg_replace($this->pattern->getRegex(), $this->replacement, $word);
37
    }
38
}
39