Completed
Pull Request — development (#3050)
by John
08:57
created

MenuSection   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

3 Methods

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