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

MenuSubsection::setActive()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 6
ccs 3
cts 3
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
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