Passed
Pull Request — master (#90)
by Jonathan
02:36
created

RulesetInflector::__construct()   A

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 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Inflector;
6
7
use Doctrine\Inflector\Rules\Ruleset;
8
9
class RulesetInflector implements WordInflector
10
{
11
    /** @var Ruleset */
12
    private $ruleset;
13
14 532
    public function __construct(Ruleset $ruleset)
15
    {
16 532
        $this->ruleset = $ruleset;
17 532
    }
18
19 516
    public function inflect(string $word) : string
20
    {
21 516
        $inflected = $this->ruleset->getIrregular()->inflect($word);
22
23 516
        if ($inflected !== null) {
24 94
            return $inflected;
25
        }
26
27 425
        if ($this->ruleset->getUninflected()->isUninflected($word)) {
28 246
            return $word;
29
        }
30
31 182
        return $this->ruleset->getRules()->inflect($word);
32
    }
33
}
34