ServerInformationLineFactory   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 58
ccs 0
cts 26
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A create() 0 24 3
1
<?php
2
3
namespace eXpansion\Bundle\ServerInformation\Ui\Factory;
4
5
6
use eXpansion\Framework\Gui\Components\Label;
7
use eXpansion\Framework\Gui\Ui\Factory;
8
use FML\Controls\Frame;
9
10
class ServerInformationLineFactory
11
{
12
    /** @var Factory */
13
    protected $factory;
14
15
    /** @var float */
16
    protected $titleWidth;
17
18
    /** @var float */
19
    protected $dataWidth;
20
21
    /**
22
     * ServerInformationLineFactory constructor.
23
     * @param Factory $factory
24
     * @param string $class
0 ignored issues
show
Bug introduced by
There is no parameter named $class. 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...
25
     * @param float $titleWidth
26
     * @param float $dataWidth
27
     */
28
    public function __construct(Factory $factory, float $titleWidth, float $dataWidth)
29
    {
30
        $this->factory = $factory;
31
        $this->titleWidth = $titleWidth;
32
        $this->dataWidth = $dataWidth;
33
    }
34
35
36
    /**
37
     * Create a server information line.
38
     *
39
     * @param $title
40
     * @param $data
41
     * @return Frame
42
     */
43
    public function create($title, $data)
44
    {
45
        if (!is_array($data)) {
46
            $data = [$data];
47
        }
48
        $nbLine = count($data);
49
50
        $frame = new Frame();
51
        $frame->setWidth($this->titleWidth + $this->dataWidth + 1);
52
        $frame->setHeight(3.5 * $nbLine);
53
54
        $frame->addChild($this->factory->createLabel($title, Label::TYPE_TITLE)->setWidth($this->titleWidth)->setTranslate(true));
55
56
        foreach ($data as $i => $dataLine) {
57
            $frame->addChild(
58
                $this->factory->createLabel($dataLine, Label::TYPE_NORMAL)
59
                    ->setWidth($this->dataWidth)
60
                    ->setX($this->titleWidth + 1)
61
                    ->setY(-3.5 * $i)
62
            );
63
        }
64
65
        return $frame;
66
    }
67
}
68