Completed
Push — master ( 120557...b81336 )
by Craig
04:55
created

AbstractExtensionMenu   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 30
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A get() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Zikula package.
7
 *
8
 * Copyright Zikula - 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\ExtensionMenu;
15
16
use Knp\Menu\FactoryInterface;
17
use Knp\Menu\ItemInterface;
18
use Zikula\PermissionsModule\Api\ApiInterface\PermissionApiInterface;
19
20
abstract class AbstractExtensionMenu implements ExtensionMenuInterface
21
{
22
    /**
23
     * @var FactoryInterface
24
     */
25
    protected $factory;
26
27
    /**
28
     * @var PermissionApiInterface
29
     */
30
    protected $permissionApi;
31
32
    public function __construct(
33
        FactoryInterface $factory,
34
        PermissionApiInterface $permissionApi
35
    ) {
36
        $this->factory = $factory;
37
        $this->permissionApi = $permissionApi;
38
    }
39
40
    public function get(string $type = self::TYPE_ADMIN): ?ItemInterface
41
    {
42
        if (self::TYPE_ADMIN === $type) {
43
            return $this->getAdmin();
44
        }
45
46
        return null;
47
    }
48
49
    abstract protected function getAdmin(): ?ItemInterface;
50
}
51