Passed
Pull Request — master (#97)
by Jonathan
02:23
created

PluralizerFactory::withIrregular()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Inflector;
6
7
use Doctrine\Inflector\Rules\English;
8
use Doctrine\Inflector\Rules\Patterns;
9
use Doctrine\Inflector\Rules\Ruleset;
10
use Doctrine\Inflector\Rules\Substitutions;
11
use Doctrine\Inflector\Rules\Transformations;
12
13
final class PluralizerFactory
14
{
15
    /** @var Transformations */
16
    private $transformations;
17
18
    /** @var Patterns */
19
    private $uninflected;
20
21
    /** @var Substitutions */
22
    private $irregular;
23
24 3
    public function withTransformations(Transformations $transformations) : self
25
    {
26 3
        $this->transformations = $transformations;
27
28 3
        return $this;
29
    }
30
31 3
    public function withUninflected(Patterns $uninflected) : self
32
    {
33 3
        $this->uninflected = $uninflected;
34
35 3
        return $this;
36
    }
37
38 3
    public function withIrregular(Substitutions $irregular) : self
39
    {
40 3
        $this->irregular = $irregular;
41
42 3
        return $this;
43
    }
44
45 527
    public function build() : Ruleset
46
    {
47 527
        $transformations = $this->transformations ?? new Transformations(...English\Inflectible::getPlural());
48 527
        $uninflected     = $this->uninflected ?? new Patterns(...English\Uninflected::getPlural());
49 527
        $irregular       = $this->irregular ?? new Substitutions(...English\Inflectible::getIrregular());
50
51 527
        return new Ruleset($transformations, $uninflected, $irregular);
52
    }
53
}
54