Passed
Push — master ( 989424...9f50f4 )
by Jonathan
29s
created

Transformations   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A inflect() 0 9 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Inflector\Rules;
6
7
use Doctrine\Inflector\WordInflector;
8
9
class Transformations implements WordInflector
10
{
11
    /** @var Transformation[] */
12
    private $transformations;
13
14 761
    public function __construct(Transformation ...$transformations)
15
    {
16 761
        $this->transformations = $transformations;
17 761
    }
18
19 342
    public function inflect(string $word) : string
20
    {
21 342
        foreach ($this->transformations as $transformation) {
22 342
            if ($transformation->getPattern()->matches($word)) {
23 342
                return $transformation->inflect($word);
24
            }
25
        }
26
27 2
        return $word;
28
    }
29
}
30