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

CacheRulesetInflector   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A inflect() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Inflector;
6
7
class CacheRulesetInflector implements WordInflector
8
{
9
    /** @var RulesetInflector */
10
    private $rulesetInflector;
11
12
    /** @var string[] */
13
    private $cache = [];
14
15 530
    public function __construct(RulesetInflector $rulesetInflector)
16
    {
17 530
        $this->rulesetInflector = $rulesetInflector;
18 530
    }
19
20 514
    public function inflect(string $word) : string
21
    {
22 514
        return $this->cache[$word] ?? $this->cache[$word] = $this->rulesetInflector->inflect($word);
23
    }
24
}
25