Completed
Pull Request — master (#99)
by De Cramer
02:57
created

WidgetFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 62
ccs 0
cts 15
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 22 1
A createManialink() 0 16 1
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\Widget;
8
use eXpansion\Framework\Core\Model\Gui\WidgetFactoryContext;
9
use eXpansion\Framework\Core\Model\Gui\Window;
10
use eXpansion\Framework\Core\Model\UserGroups\Group;
11
use eXpansion\Framework\Core\Plugins\GuiHandler;
12
use eXpansion\Framework\Core\Plugins\UserGroups\Factory;
13
use FML\Controls\Control;
14
15
/**
16
 * Class ManialiveFactory allow the creation of manialinks.
17
 *
18
 * @package eXpansion\Framework\Core\Plugins\Gui
19
 * @author Oliver de Cramer
20
 */
21
class WidgetFactory extends ManialinkFactory {
22
23
    /** @var Translations */
24
    protected $translationsHelper;
25
26
    /**
27
     * WidgetFactory constructor.
28
     *
29
     * @param                      $name
30
     * @param                      $sizeX
31
     * @param                      $sizeY
32
     * @param null                 $posX
33
     * @param null                 $posY
34
     * @param WidgetFactoryContext $context
35
     */
36
    public function __construct(
37
        $name,
38
        $sizeX,
39
        $sizeY,
40
        $posX,
41
        $posY,
42
        WidgetFactoryContext $context
43
    ) {
44
        // Hack for FML to use default MP alignements.
45
        Control::clearDefaultAlign();
46
47
        parent::__construct(
48
            $name,
49
            $sizeX,
50
            $sizeY,
51
            $posX,
52
            $posY,
53
            $context
54
        );
55
56
        $this->translationsHelper = $context->getTranslationsHelper();
57
    }
58
59
    /**
60
     * @param Group $group
61
     *
62
     * @return Window
63
     */
64
    protected function createManialink(Group $group)
65
    {
66
67
        $className = $this->className;
68
        $manialink = new $className(
69
            $group,
70
            $this->translationsHelper,
71
            $this->name,
72
            $this->sizeX,
73
            $this->sizeY,
74
            $this->posX,
75
            $this->posY
76
        );
77
78
        return $manialink;
79
    }
80
81
82
}
83