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

ItemChatCommandFactory::__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\ChatCommandItem;
6
use eXpansion\Bundle\Menu\Model\Menu\ItemInterface;
7
use eXpansion\Bundle\Menu\Services\ItemFactoryInterface;
8
use eXpansion\Framework\AdminGroups\Helpers\AdminGroups;
9
use eXpansion\Framework\Core\DataProviders\ChatCommandDataProvider;
10
use FML\Controls\Quad;
11
12
/**
13
 * Class ItemChatCommandFactory
14
 *
15
 * @author    de Cramer Oliver<[email protected]>
16
 * @copyright 2017 Smile
17
 * @package eXpansion\Bundle\Menu\Services\Factories
18
 */
19 View Code Duplication
class ItemChatCommandFactory 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
22
    /** @var ChatCommandDataProvider */
23
    protected $chatCommandProvider;
24
25
    /** @var AdminGroups */
26
    protected $adminGroups;
27
28
    /**
29
     * ItemChatCommandFactory constructor.
30
     *
31
     * @param ChatCommandDataProvider $chatCommandProvider
32
     */
33
    public function __construct(AdminGroups $adminGroups, ChatCommandDataProvider $chatCommandProvider)
34
    {
35
        $this->chatCommandProvider = $chatCommandProvider;
36
        $this->adminGroups = $adminGroups;
37
    }
38
39
    /**
40
     * Check if item factory supports building a certain class.
41
     *
42
     * @param string $class
43
     *
44
     * @return boolean
45
     */
46
    public function supports($class)
47
    {
48
        return $class == ChatCommandItem::class;
49
    }
50
51
    /**
52
     * Creates a new Menu item
53
     *
54
     * @param string $class Class of the item.
55
     * @param string $id Id of the item
56
     * @param string $path Path of the item
57
     * @param string $label
58
     * @param string $permission
59
     * @param array $options
60
     *
61
     * @return ItemInterface
62
     */
63
    public function build($class, $id, $path, $label, $permission, $options = [])
64
    {
65
        return new ChatCommandItem(
66
            $this->chatCommandProvider,
67
            $options['cmd'],
68
            $id,
69
            $path,
70
            $label,
71
            $this->adminGroups,
72
            $permission
73
        );
74
    }
75
}