Completed
Push — dev ( 845ef5...8eacd8 )
by
unknown
02:50
created

WidgetFactory::createManialink()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 0
cts 11
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 11
nc 1
nop 1
crap 2
1
<?php
2
3
namespace eXpansion\Framework\Core\Plugins\Gui;
4
use eXpansion\Framework\Core\Helpers\Translations;
5
use eXpansion\Framework\Core\Model\Gui\Manialink;
6
use eXpansion\Framework\Core\Model\Gui\ManiaScriptFactory;
7
use eXpansion\Framework\Core\Model\Gui\Window;
8
use eXpansion\Framework\Core\Model\UserGroups\Group;
9
use eXpansion\Framework\Core\Plugins\GuiHandler;
10
use eXpansion\Framework\Core\Plugins\UserGroups\Factory;
11
use FML\Controls\Control;
12
13
/**
14
 * Class ManialiveFactory allow the creation of manialinks.
15
 *
16
 * @package eXpansion\Framework\Core\Plugins\Gui
17
 * @author Oliver de Cramer
18
 */
19
class WidgetFactory extends ManialinkFactory {
20
21
    /** @var Translations */
22
    protected $translationsHelper;
23
24
    /**
25
     * WidgetFactory constructor.
26
     *
27
     * @param               $name
28
     * @param               $sizeX
29
     * @param               $sizeY
30
     * @param null          $posX
31
     * @param null          $posY
32
     * @param GuiHandler    $guiHandler
33
     * @param Factory       $groupFactory
34
     * @param ActionFactory $actionFactory
35
     * @param Translations  $translationsHelper
36
     * @param string        $className
37
     */
38 View Code Duplication
    public function __construct(
0 ignored issues
show
Duplication introduced by
This method 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...
39
        $name,
40
        $sizeX,
41
        $sizeY,
42
        $posX,
43
        $posY,
44
        GuiHandler $guiHandler,
45
        Factory $groupFactory,
46
        ActionFactory $actionFactory,
47
        Translations $translationsHelper,
48
        $className = Window::class
49
    ) {
50
        // Hack for FML to use default MP alignements.
51
        Control::clearDefaultAlign();
52
53
        parent::__construct(
54
            $name,
55
            $sizeX,
56
            $sizeY,
57
            $posX,
58
            $posY,
59
            $guiHandler,
60
            $groupFactory,
61
            $actionFactory,
62
            $className
63
        );
64
65
        $this->translationsHelper = $translationsHelper;
66
    }
67
68
    /**
69
     * @param Group $group
70
     *
71
     * @return Window
72
     */
73
    protected function createManialink(Group $group)
74
    {
75
        $className = $this->className;
76
        $manialink = new $className(
77
            $group,
78
            $this->translationsHelper,
79
            $this->name,
80
            $this->sizeX,
81
            $this->sizeY,
82
            $this->posX,
83
            $this->posY
84
        );
85
86
        return $manialink;
87
    }
88
}
89