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

WidgetFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 70
Duplicated Lines 41.43 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 29
loc 70
ccs 0
cts 25
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B __construct() 29 29 1
A createManialink() 0 15 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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