Completed
Push — master ( 412cc9...332cd3 )
by Peter
04:16
created

DocNavRecursive   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 27 5
A __toString() 0 9 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: peter
5
 * Date: 26.07.17
6
 * Time: 15:49
7
 */
8
9
namespace Maslosoft\Zamm\Widgets;
10
11
12
use Maslosoft\Staple\Widgets\SubNavRecursive;
13
14
class DocNavRecursive extends SubNavRecursive
15
{
16
	public $title = '';
17
18
	public function __construct($options = [])
19
	{
20
		if(is_string($options))
21
		{
22
			$this->title = $options;
23
			$options = [];
24
		}
25
		$root = __DIR__;
26
		if(empty($options['root']))
27
		{
28
			$trace = debug_backtrace(null, 1);
29
			$root = dirname($trace[0]['file']);
30
		}
31
		$defaults = [
32
			'root' => $root,
33
			'path' => '.',
34
			'skipLevel' => 1
35
		];
36
		foreach ($defaults as $name => $value)
37
		{
38
			if (!array_key_exists($name, $options))
39
			{
40
				$options[$name] = $value;
41
			}
42
		}
43
		parent::__construct($options);
44
	}
45
46
	public function __toString()
47
	{
48
		$prefix = '';
49
		if($this->title)
50
		{
51
			$prefix = '<h3>' . $this->title . '</h3>' . "\n";
52
		}
53
		return $prefix . parent::__toString() . "\n\n";
54
	}
55
}