Completed
Pull Request — development (#3050)
by John
23:37
created

MenuSubsection   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 73.32%

Importance

Changes 0
Metric Value
dl 0
loc 62
ccs 11
cts 15
cp 0.7332
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 setDefault() 0 6 1
A setActive() 0 6 1
A isDefault() 0 4 1
A getActive() 0 4 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
14
namespace ElkArte\Menu;
15
16
class MenuSubsection extends MenuItem
17
{
18
	/** @var bool $default Is this the default subaction - if not set for any will default to first... */
19
	protected $default = false;
20
21
	/** @var string[] $active Set the button active for other subsections. */
22
	protected $active = [];
23
24
	/**
25
	 * @param array $arr
26
	 *
27
	 * @return MenuSubsection
28
	 */
29 41
	protected function buildMoreFromArray(array $arr): MenuSubsection
30
	{
31 41
		$this->label = $arr[0];
32 41
		$this->permission = isset($arr[1]) ? (array) $arr[1] : [];
33 41
		$this->default = isset($arr[2]) ? (bool) $arr[2] : false;
34
35 41
		return $this;
36
	}
37
38
	/**
39
	 * @return boolean
40
	 */
41
	public function isDefault(): bool
42
	{
43
		return $this->default;
44
	}
45
46
	/**
47
	 * @param boolean $default
48
	 *
49
	 * @return MenuSubsection
50
	 */
51 41
	public function setDefault(bool $default): MenuSubsection
52
	{
53 41
		$this->default = $default;
54
55 41
		return $this;
56
	}
57
58
	/**
59
	 * @return string[]
60
	 */
61
	public function getActive(): array
62
	{
63
		return $this->active;
64
	}
65
66
	/**
67
	 * @param string[] $active
68
	 *
69
	 * @return MenuSubsection
70
	 */
71 41
	public function setActive(array $active): MenuSubsection
72
	{
73 41
		$this->active = $active;
74
75 41
		return $this;
76
	}
77
}
78