Completed
Push — master ( cee455...7b2535 )
by Ryun
01:50
created

Bootstrap4Presenter::getActiveLink()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php namespace Humweb\Breadcrumbs;
2
3
class Bootstrap4Presenter {
4
5
	protected $breadcrumb;
6
7
	public function __construct(Breadcrumbs $breadcrumb)
8
	{
9
		$this->breadcrumb = $breadcrumb;
10
	}
11
12
	/**
13
	 * Render the Bootstrap breadcrumbs contents.
14
	 *
15
	 * @return string
16
	 */
17
	public function render()
18
	{
19
		$pages = array();
20
		$crumbs = $this->breadcrumb->toArray();
21
22
		foreach ($crumbs as $item)
23
		{
0 ignored issues
show
Coding Style introduced by
Blank line found at start of control structure
Loading history...
24
25
			if ( empty($item['url']) )
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
26
			{
27
				$pages[] = $this->getActiveLink($item);
28
			}
29
			else
0 ignored issues
show
Coding Style introduced by
Expected 1 space after ELSE keyword; newline found
Loading history...
30
			{
31
				$pages[] = $this->getLink($item);
32
			}
33
		}
34
		return $this->getWrapper(implode('', $pages));
35
	}
36
37
	public function getWrapper($items)
38
	{
39
		return '<ol class="breadcrumb">'.$items.'</ol>';
40
	}
41
42
	public function getLink($item)
43
	{
44
		return '<li class="breadcrumb-item"><a href="'.$item['url'].'">'.$item['label'].'</a></li>';
45
	}
46
47
	public function getActiveLink($item)
48
	{
49
		return '<li class="breadcrumb-item active">'.$item['label'].'</li>';
50
	}
51
}
52