Completed
Push — master ( 3f8e75...6b7568 )
by Gabriel
02:02
created

Trail::renderer()   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
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 2
rs 10
1
<?php
2
3
namespace ByTIC\Navigation\Breadcrumbs;
4
5
/**
6
 * Class Trail
7
 * @package ByTIC\Navigation\Breadcrumbs
8
 */
9
class Trail
10
{
11
12
    /**
13
     * The breadcrumb trail.
14
     *
15
     * @var Breadcrumbs
16
     */
17
    protected $breadcrumbs;
18
19
    protected $renderer = null;
20
21
    /**
22
     * Trail constructor.
23
     */
24 3
    public function __construct()
25
    {
26 3
        $this->breadcrumbs = new Breadcrumbs();
27 3
    }
28
29
    /**
30
     * @param $name
31
     * @param $arguments
32
     * @return mixed
33
     */
34 2
    public function __call($name, $arguments)
35
    {
36 2
        return call_user_func_array([$this->breadcrumbs, $name], $arguments);
37
    }
38
39
    /**
40
     * @return string
41
     */
42 2
    public function render()
43
    {
44 2
        if (count($this->breadcrumbs) < 1) {
45 1
            return null;
46
        }
47 1
        return $this->renderer()->render();
48
    }
49
50
    /**
51
     * @return BreadcrumbsRenderer
52
     */
53 1
    public function renderer()
54
    {
55 1
        if ($this->renderer === null) {
56 1
             $this->renderer = new BreadcrumbsRenderer($this->breadcrumbs);
57
        }
58 1
        return $this->renderer;
59
    }
60
61
    /**
62
     * @return string
63
     */
64
    public function __toString()
65
    {
66
        return $this->render();
67
    }
68
}
69