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

HasUrlTransformerTrait::initUrlTransformer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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