CustomMenuItem::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 2
eloc 5
nc 2
nop 1
1
<?php namespace rtens\domin\delivery\web\menu;
2
3
use rtens\domin\delivery\web\Element;
4
5
class CustomMenuItem implements MenuItem {
6
7
    /** @var callable */
8
    private $content;
9
10
    /**
11
     * CustomMenuItem constructor.
12
     * @param Element|string|callable $content
13
     */
14
    public function __construct($content) {
15
        if (!is_callable($content)) {
16
            $content = function () use ($content) {
17
                return $content;
18
            };
19
        }
20
        $this->content = $content;
21
    }
22
23
    public function render() {
24
        return new Element('li', [], [
25
            call_user_func($this->content)
26
        ]);
27
    }
28
}