Transformations::inflect()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 10
cc 3
nc 3
nop 1
crap 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 1107
    public function __construct(Transformation ...$transformations)
15
    {
16 1107
        $this->transformations = $transformations;
17 1107
    }
18
19 490
    public function inflect(string $word) : string
20
    {
21 490
        foreach ($this->transformations as $transformation) {
22 489
            if ($transformation->getPattern()->matches($word)) {
23 484
                return $transformation->inflect($word);
24
            }
25
        }
26
27 6
        return $word;
28
    }
29
}
30