Completed
Push — master ( e09c01...ac9146 )
by De Cramer
02:18 queued 02:12
created

ItemParentFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 5
Ratio 100 %

Importance

Changes 0
Metric Value
dl 5
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
namespace eXpansion\Bundle\Menu\Services\Factories;
4
5
use eXpansion\Bundle\Menu\Model\Menu\ItemInterface;
6
use eXpansion\Bundle\Menu\Model\Menu\ParentItem;
7
use eXpansion\Bundle\Menu\Services\ItemBuilder;
8
use eXpansion\Bundle\Menu\Services\ItemFactoryInterface;
9
use eXpansion\Framework\AdminGroups\Helpers\AdminGroups;
10
use FML\Controls\Quad;
11
12
/**
13
 * Class ItemParentFactory
14
 *
15
 * @author    de Cramer Oliver<[email protected]>
16
 * @copyright 2017 Smile
17
 * @package eXpansion\Bundle\Menu\Services
18
 */
19 View Code Duplication
class ItemParentFactory implements ItemFactoryInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
20
{
21
    /** @var ItemBuilder */
22
    protected $itemBuilder;
23
24
    /** @var AdminGroups */
25
    protected $adminGroups;
26
27
    /**
28
     * ItemParentFactory constructor.
29
     *
30
     * @param ItemBuilder $itemBuilder
31
     */
32
    public function __construct(AdminGroups $adminGroups, ItemBuilder $itemBuilder)
33
    {
34
        $this->itemBuilder = $itemBuilder;
35
        $this->adminGroups = $adminGroups;
36
    }
37
38
    /**
39
     * Check if item factory supports building a certain class.
40
     *
41
     * @param string $class
42
     *
43
     * @return boolean
44
     */
45
    public function supports($class)
46
    {
47
       return $class == ParentItem::class;
48
    }
49
50
    /**
51
     * Creates a new Menu item
52
     *
53
     * @param string $class Class of the item.
54
     * @param string $id Id of the item
55
     * @param string $path Path of the item
56
     * @param string $label
57
     * @param string $permission
58
     * @param array $options
59
     *
60
     * @return ItemInterface
61
     */
62
    public function build($class, $id, $path, $label, $permission, $options = [])
63
    {
64
        return new ParentItem(
65
            $this->itemBuilder,
66
            $id,
67
            $path,
68
            $label,
69
            $this->adminGroups,
70
            $permission
71
        );
72
    }
73
}
74