Transformations::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
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 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