Transformations   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

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 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