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

Transformations::__construct()   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 1
crap 1
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