Completed
Push — master ( 3b8fc6...fa37fa )
by ARCANEDEV
10:04
created

MenuItemAttributes   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 72.21%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 40
ccs 13
cts 18
cp 0.7221
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A render() 0 18 4
A __toString() 0 4 1
1
<?php namespace Arcanedev\Menus\Entities;
2
3
use Arcanedev\Menus\Contracts\Renderable;
4
use Arcanedev\Support\Collection;
5
6
/**
7
 * Class     MenuItemAttributes
8
 *
9
 * @package  Arcanedev\Menus\Entities
10
 * @author   ARCANEDEV <[email protected]>
11
 */
12
class MenuItemAttributes extends Collection implements Renderable
13
{
14
    /* ------------------------------------------------------------------------------------------------
15
     |  Main Functions
16
     | ------------------------------------------------------------------------------------------------
17
     */
18
    /**
19
     * Render the instance to string.
20
     *
21
     * @return string
22
     */
23 15
    public function render()
24
    {
25 15
        $html = [];
26
27 15
        foreach ($this->all() as $key => $value) {
28 15
            if (is_null($value)) {
29 5
                continue;
30
            }
31
32 15
            if (is_numeric($key)) {
33 5
                $key = $value;
34 5
            }
35
36 15
            $html[] = $key . '="' . e($value) . '"';
37 15
        }
38
39 15
        return implode(' ', array_filter($html));
40
    }
41
42
    /**
43
     * Render the instance to string.
44
     *
45
     * @return string
46
     */
47 5
    public function __toString()
48
    {
49 5
        return $this->render();
50
    }
51
}
52