Completed
Push — master ( c7b167...faaa80 )
by Wanderson
02:08
created

BreadCrumb   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A createLink() 0 14 4
A getLink() 0 3 1
A getText() 0 3 1
A setText() 0 3 1
1
<?php
2
3
/**
4
 * BreadCrumbs
5
 * Cria breadcrumbs personalizados
6
 * Exemplo de um breadcrumb:	 Página Inicial > Produto > Óculos de Sol
7
 * @author WebCorpore
8
 */
9
10
namespace Win\Html;
11
12
use Win\Mvc\Application;
13
14
class BreadCrumb {
15
16
	private static $text;
17
18
	/**
19
	 * Melhora o BreadCrumb, adicionando Links se possível
20
	 * @param string $breadCrumb apenas texto
21
	 * @return string BreadCrumb com Links
22
	 */
23
	public static function createLink($breadCrumb) {
24
		$app = Application::app();
25
26
		$baseLink = explode('»', $breadCrumb, 2);
27
		if (count($baseLink) > 1) {
28
			if ($app->controller->getAction() != 'index' and trim($baseLink[0]) != 'Página Inicial') {
29
				return '<a href="' . $app->getPage() . '/">' . $baseLink[0] . '</a> » ' . $baseLink[1];
30
			} else {
31
				return '<a href="">' . $baseLink[0] . '</a> » ' . $baseLink[1];
32
			}
33
		} else {
34
			return $breadCrumb;
35
		}
36
	}
37
38
	public static function getLink() {
39
		return static::createLink(static::getText());
40
	}
41
42
	public static function getText() {
43
		return self::$text;
44
	}
45
46
	public static function setText($text) {
47
		self::$text = $text;
48
	}
49
50
}
51