Passed
Push — master ( 6137ca...01151b )
by Kevin
02:21
created

WithNormalizer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 85.71%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 6
c 1
b 0
f 1
dl 0
loc 16
ccs 6
cts 7
cp 0.8571
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setNormalizer() 0 3 1
A normalizer() 0 7 2
1
<?php
2
3
namespace Zenstruck\Porpaginas\Specification\Normalizer;
4
5
use Zenstruck\Porpaginas\Specification\Normalizer;
6
7
/**
8
 * @author Kevin Bond <[email protected]>
9
 */
10
trait WithNormalizer
11
{
12
    private ?Normalizer $normalizer = null;
13
14 4
    public function setNormalizer(Normalizer $normalizer): void
15
    {
16 4
        $this->normalizer = $normalizer;
17 4
    }
18
19 6
    protected function normalizer(): Normalizer
20
    {
21 6
        if (!$this->normalizer) {
22
            throw new \RuntimeException('A normalizer has not been set.');
23
        }
24
25 6
        return $this->normalizer;
26
    }
27
}
28