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

MenuSection   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 48
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0
wmc 6
lcom 1
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A addArea() 0 6 1
A getAreas() 0 4 1
A buildMoreFromArray() 0 16 4
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 MenuSection extends MenuItem
17
{
18
	/** @var array $areas Array of areas within this section. */
19
	private $areas = [];
20
21
	/**
22
	 * @param array $arr
23
	 *
24
	 * @return MenuSection
25
	 */
26 41
	protected function buildMoreFromArray(array $arr): MenuSection
27
	{
28 41
		if (isset($arr['title']))
29
		{
30 41
			$this->setLabel($arr['title']);
31
		}
32 41
		if (isset($arr['areas']))
33
		{
34 41
			foreach ($arr['areas'] as $var => $area)
35
			{
36 41
				$this->addArea($var, $area);
37
			}
38
		}
39
40 41
		return $this;
41
	}
42
43
	/**
44
	 * @param string   $id
45
	 * @param MenuArea $area
46
	 *
47
	 * @return $this
48
	 */
49 41
	public function addArea(string $id, MenuArea $area): MenuSection
50
	{
51 41
		$this->areas[$id] = $area;
52
53 41
		return $this;
54
	}
55
56
	/**
57
	 * @return array
58
	 */
59 39
	public function getAreas(): array
60
	{
61 39
		return $this->areas;
62
	}
63
}
64