Completed
Pull Request — master (#130)
by
unknown
02:52
created

WindowFrameFactory::setManialinkInterface()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 0
cts 3
cp 0
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
namespace eXpansion\Bundle\ImmersiveWindows\Model\Gui\Factory;
4
5
use eXpansion\Bundle\Menu\DataProviders\MenuItemProvider;
6
use eXpansion\Bundle\Menu\Gui\MenuTabsFactory;
7
use eXpansion\Framework\Core\Model\Gui\Factory\WindowFrameFactory as OriginalWindowFrameFactory;
8
use eXpansion\Framework\Core\Model\Gui\ManialinkInterface;
9
use eXpansion\Framework\Core\Model\Gui\ManiaScriptFactory;
10
use FML\Controls\Frame;
11
use FML\Controls\Label;
12
use FML\Controls\Quad;
13
use FML\ManiaLink;
14
15
/**
16
 * Class WindowFrameFactory
17
 *
18
 * @author    de Cramer Oliver<[email protected]>
19
 * @copyright 2017 Smile
20
 * @package eXpansion\Bundle\ImmersiveWindows\Model\Gui\Factory
21
 */
22
class WindowFrameFactory extends OriginalWindowFrameFactory
23
{
24
    /** @var MenuTabsFactory */
25
    protected $menuTabsFactory;
26
27
    /** @var MenuItemProvider */
28
    protected $menuItemProvider;
29
    /**
30
     * @var ManiaScriptFactory
31
     */
32
    protected $maniaScriptFactory;
33
    /**
34
     * @var ManialinkInterface
35
     */
36
    protected $manialinkInterface;
37
38
    /**
39
     * WindowFrameFactory constructor.
40
     *
41
     * @param ManiaScriptFactory $maniaScriptFactory
42
     * @param MenuTabsFactory $menuTabsFactory
43
     * @param MenuItemProvider $menuItemProvider
44
     * @param ManialinkInterface $manialink
0 ignored issues
show
Bug introduced by
There is no parameter named $manialink. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
45
     */
46
    public function __construct(
47
        ManiaScriptFactory $maniaScriptFactory,
48
        MenuTabsFactory $menuTabsFactory,
49
        MenuItemProvider $menuItemProvider
50
    ) {
51
        parent::__construct($maniaScriptFactory);
52
        $this->maniaScriptFactory = $maniaScriptFactory;
53
        $this->menuTabsFactory = $menuTabsFactory;
54
        $this->menuItemProvider = $menuItemProvider;
55
56
    }
57
58
    /**
59
     * @inheritdoc
60
     */
61
    public function build(
62
        ManiaLink $manialink,
63
        Frame $mainFrame,
64
        $name,
65
        $sizeX,
66
        $sizeY
67
    ) {
68
        // Creating sub frame to keep all the pieces together. Position needs to be top left corner.
69
        $frame = new Frame();
70
        $frame->setPosition(-144 - $mainFrame->getX(), 82 - $mainFrame->getY());
71
        $mainFrame->addChild($frame);
72
73
        // Creating the tabs.
74
        $mainFrame->addChild(
75
            $this->menuTabsFactory->createTabsMenu(
0 ignored issues
show
Documentation introduced by
$this->menuTabsFactory->...tItem(), 'admin/admin') is of type object<FML\Types\Container>, but the function expects a object<FML\Types\Renderable>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
76
                $this->manialinkInterface,
77
                $frame,
78
                $this->menuItemProvider->getRootItem(),
0 ignored issues
show
Documentation introduced by
$this->menuItemProvider->getRootItem() is of type object<eXpansion\Bundle\...enu\ItemInterface>|null, but the function expects a object<eXpansion\Bundle\...\Model\Menu\ParentItem>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
79
                'admin/admin'
80
            )
81
        );
82
83
        $closeButton = new Label('Close');
84
        $closeButton->setSize(6, 6)
85
            ->setPosition(132, 72)
86
            ->setAlign(Label::CENTER, Label::CENTER2)
87
            ->setText("✖")
88
            ->setTextColor('fff')
89
            ->setTextSize(2)
90
            ->setTextFont('OswaldMono')
91
            ->setScriptEvents(true)
92
            ->setAreaColor("FFF")
93
            ->setAreaFocusColor('f22');
94
        $frame->addChild($closeButton);
95
96
        /*
97
         * Adding background frame
98
         */
99
        $bgFrame = Frame::create("background");
100
101
        $quad = new Quad();
102
        $quad->addClass("bg")
103
            ->setId("mainBg")
104
            ->setPosition(0, 0)
105
            ->setSize(322, 182);
106
        $quad->setAlign("center", "center")
107
            ->setStyles("Bgs1", "BgDialogBlur");
108
        $bgFrame->addChild($quad);
109
110
        $frame->addChild($bgFrame);
111
112
        return $closeButton;
113
    }
114
115
    /**
116
     * @param ManialinkInterface $manialinkInterface
117
     */
118
    public function setManialinkInterface(ManialinkInterface $manialinkInterface)
119
    {
120
        $this->manialinkInterface = $manialinkInterface;
121
    }
122
123
124
}
125