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

HasUrlTransformerTrait::getUrlTransformer()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
nc 2
nop 0
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 2
rs 10
c 1
b 0
f 0
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
}