Passed
Push — master ( cd9417...6e4265 )
by Gabriel
03:32 queued 12s
created

HasUrlTransformerTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getUrlTransformer() 0 6 2
A setUrlTransformer() 0 3 1
A initUrlTransformer() 0 3 1
1
<?php
2
3
namespace Nip\Mvc\Sections\UrlTransformer;
4
5
/**
6
 * Trait HasUrlTransformerTrait
7
 * @package Nip\Mvc\Sections\UrlTransformer
8
 */
9
trait HasUrlTransformerTrait
10
{
11
    /**
12
     * @var UrlTransformer
13
     */
14
    protected $urlTransformer = null;
15
16
    /**
17
     * @return UrlTransformer
18
     */
19 4
    public function getUrlTransformer(): UrlTransformer
20
    {
21 4
        if ($this->urlTransformer == null) {
22 4
            $this->initUrlTransformer();
23
        }
24 4
        return $this->urlTransformer;
25
    }
26
27
    /**
28
     * @param UrlTransformer $urlTransformer
29
     */
30 4
    public function setUrlTransformer(UrlTransformer $urlTransformer)
31
    {
32 4
        $this->urlTransformer = $urlTransformer;
33 4
    }
34
35 4
    protected function initUrlTransformer()
36
    {
37 4
        $this->setUrlTransformer(UrlTransformer::from());
38
    }
39
}