Completed
Push — master ( 33f65d...fb9c39 )
by Richard
12s
created

ItemList   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 36
rs 10
ccs 6
cts 6
cp 1
wmc 3
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A addItem() 0 5 1
1
<?php
2
/*
3
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
 */
11
12
namespace Xoops\Html\Menu;
13
14
/**
15
 * ItemList - a list of menu items
16
 *
17
 * @category  Xoops\Html\Menu
18
 * @package   Link
19
 * @author    Richard Griffith <[email protected]>
20
 * @copyright 2016 XOOPS Project (http://xoops.org)
21
 * @license   GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
22
 * @link      http://xoops.org
23
 */
24
class ItemList extends Item
25
{
26
    /**
27
     * __construct
28
     *
29
     * @param array $attributes array of attribute name => value pairs
30
     *
31
     * Possible attributes:
32
     *   'items'    - Item[] (optional, can be added with addItem())
33
     *   'caption'  - link caption (required for dropdowns)
34
     *   'icon'     - css classes for icon, i.e. "glyphicon glyphicon-ok"
35
     *   'id'       - element id for container association (i.e. aria-labelledby)
36
     *   'dropdown' - override "dropdown" class, i.e. "dropup"
37
     */
38 1
    public function __construct($attributes = array())
39
    {
40 1
        parent::__construct($attributes);
41 1
        $this->set('type', Item::TYPE_LIST);
42 1
        if (!$this->has('items')) {
43 1
            $this->set('items', []);
44
        }
45 1
    }
46
47
    /**
48
     * Add an item to the ItemList
49
     *
50
     * @param Item $item item to add
51
     *
52
     * @return $this for fluent access
53
     */
54
    public function addItem(Item $item)
55
    {
56
        $this['items'][] = $item;
57
        return $this;
58
    }
59
}
60