Test Setup Failed
Push — master ( 195648...185a1e )
by Craig
58s queued 15s
created

BarExtensionMenu::get()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 4
c 1
b 0
f 1
nc 2
nop 1
dl 0
loc 8
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Zikula package.
7
 *
8
 * Copyright Zikula Foundation - https://ziku.la/
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Zikula\MenuModule\Tests\ExtensionMenu\Fixtures;
15
16
use Knp\Menu\FactoryInterface;
17
use Knp\Menu\ItemInterface;
18
use Zikula\MenuModule\ExtensionMenu\ExtensionMenuInterface;
19
20
class BarExtensionMenu implements ExtensionMenuInterface
21
{
22
    /**
23
     * @var FactoryInterface
24
     */
25
    private $factory;
26
27
    public function __construct(
28
        FactoryInterface $factory
29
    ) {
30
        $this->factory = $factory;
31
    }
32
33
    public function get(string $type = self::TYPE_ADMIN): ?ItemInterface
34
    {
35
        $method = 'get' . ucfirst($type);
36
        if (method_exists($this, $method)) {
37
            return $this->{$method}();
38
        }
39
40
        return null;
41
    }
42
43
    private function getUser(): ?ItemInterface
44
    {
45
        $menu = $this->factory->createItem('admin');
46
        $menu->addChild('list', [
47
            'route' => 'list',
48
        ])->setAttribute('icon', 'fas fa-list');
49
        $menu->addChild('new', [
50
            'route' => 'edit',
51
        ]);
52
53
        return $menu;
54
    }
55
56
    private function getBar(): ?ItemInterface
57
    {
58
        $menu = $this->factory->createItem('foo');
59
        $menu->addChild('bar admin', [
60
            'route' => 'bar_admin',
61
        ])->setAttribute('icon', 'fas fa-plus');
62
63
        return $menu;
64
    }
65
66
    private function getAccount(): ?ItemInterface
67
    {
68
        $menu = $this->factory->createItem('account');
69
        $menu->addChild('bar acct', [
70
            'route' => 'bar_acct',
71
        ]);
72
73
        return $menu;
74
    }
75
76
    public function getBundleName(): string
77
    {
78
        return 'ZikulaBarExtension';
79
    }
80
}
81