Completed
Pull Request — development (#3050)
by John
09:17
created

MenuSubsection   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 62
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0
wmc 7
lcom 1
cbo 1

5 Methods

Rating   Name   Duplication   Size   Complexity  
A buildMoreFromArray() 0 8 3
A isDefault() 0 4 1
A setDefault() 0 6 1
A getActive() 0 4 1
A setActive() 0 6 1
1
<?php
2
3
/**
4
 * This class contains a standard way of displaying side/drop down menus.
5
 *
6
 * @name      ElkArte Forum
7
 * @copyright ElkArte Forum contributors
8
 * @license   BSD http://opensource.org/licenses/BSD-3-Clause
9
 *
10
 * @version   2.0 dev
11
 */
12
13
namespace ElkArte\Menu;
14
15
/**
16
 * Class MenuSubsection
17
 *
18
 * This class implements a standard way of creating menus
19
 *
20
 * @package ElkArte\Menu
21
 */
22
class MenuSubsection extends MenuItem
23
{
24
	/** @var bool $default Is this the default subaction - if not set for any will default to first... */
25
	protected $default = false;
26
27
	/** @var string[] $active Set the button active for other subsections. */
28
	protected $active = [];
29
30
	/**
31
	 * @param array $arr
32
	 *
33
	 * @return MenuSubsection
34
	 */
35 41
	protected function buildMoreFromArray(array $arr): MenuSubsection
36
	{
37 41
		$this->label = $arr[0];
38 41
		$this->permission = isset($arr[1]) ? (array) $arr[1] : [];
39 41
		$this->default = isset($arr[2]) ? (bool) $arr[2] : false;
40
41 41
		return $this;
42
	}
43
44
	/**
45
	 * @return boolean
46
	 */
47 6
	public function isDefault(): bool
48
	{
49 6
		return $this->default;
50
	}
51
52
	/**
53
	 * @param boolean $default
54
	 *
55
	 * @return MenuSubsection
56
	 */
57 41
	public function setDefault(bool $default): MenuSubsection
58
	{
59 41
		$this->default = $default;
60
61 41
		return $this;
62
	}
63
64
	/**
65
	 * @return string[]
66
	 */
67 6
	public function getActive(): array
68
	{
69 6
		return $this->active;
70
	}
71
72
	/**
73
	 * @param string[] $active
74
	 *
75
	 * @return MenuSubsection
76
	 */
77 41
	public function setActive(array $active): MenuSubsection
78
	{
79 41
		$this->active = $active;
80
81 41
		return $this;
82
	}
83
}
84