BreadcrumbsService   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 2
cbo 1
dl 0
loc 67
c 0
b 0
f 0
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A addItem() 0 6 1
A getTemplate() 0 4 1
A getSeparator() 0 5 1
A getList() 0 4 1
A getBreadcrumbs() 0 4 1
1
<?php
2
3
namespace BreadcrumbsBundle\Service;
4
5
use BreadcrumbsBundle\Model\Breadcrumbs;
6
7
/**
8
 * Class BreadcrumbsService
9
 * @package BreadcrumbsBundle\Service
10
 */
11
class BreadcrumbsService
12
{
13
    /**
14
     * @var array
15
     */
16
    protected $options;
17
18
    /**
19
     * @var Breadcrumbs
20
     */
21
    protected $breadcrumbs;
22
23
    /**
24
     * BreadcrumbsService constructor.
25
     * @param array $options
26
     */
27
    public function __construct(array $options)
28
    {
29
        $this->options = $options;
30
        $this->breadcrumbs = new Breadcrumbs();
31
    }
32
33
    /**
34
     * @param string $text
35
     * @param string|null $url
36
     * @return BreadcrumbsService
37
     */
38
    public function addItem(string $text, string $url = null): BreadcrumbsService
39
    {
40
        $this->breadcrumbs->addItem($text, $url);
41
42
        return $this;
43
    }
44
45
    /**
46
     * @return string
47
     */
48
    public function getTemplate(): string
49
    {
50
        return $this->options['template'];
51
    }
52
53
    /**
54
     * @return array
55
     */
56
    public function getSeparator(): array
57
    {
58
59
        return $this->options['separator'];
60
    }
61
62
    /**
63
     * @return array
64
     */
65
    public function getList(): array
66
    {
67
        return $this->options['list'];
68
    }
69
70
    /**
71
     * @return Breadcrumbs
72
     */
73
    public function getBreadcrumbs(): Breadcrumbs
74
    {
75
        return $this->breadcrumbs;
76
    }
77
}