Trail::__call()   A
last analyzed

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
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
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