Completed
Pull Request — master (#51)
by De Cramer
02:42
created

LabelFactory::create()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 19
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 19
ccs 0
cts 16
cp 0
rs 9.4285
cc 3
eloc 12
nc 4
nop 3
crap 12
1
<?php
2
3
namespace eXpansion\Framework\Core\Model\Gui\Factory;
4
use FML\Controls\Label;
5
6
/**
7
 * Class LineBuilder
8
 *
9
 * @package eXpansion\Framework\Core\Model\Gui\Builders;
10
 * @author  oliver de Cramer <[email protected]>
11
 */
12
class LabelFactory
13
{
14
    const TYPE_NORMAL = "normal";
15
    const TYPE_TITLE = 'title';
16
17
    public function create($text, $translate = false, $type = self::TYPE_NORMAL)
18
    {
19
        $label = new Label();
20
        $label->setTextSize(2)
21
            ->setHeight(4)
22
            ->setTranslate($translate);
23
24
        if ($translate) {
25
            $label->setTextId($text);
26
        } else {
27
            $label->setText($text);
28
        }
29
30
        if ($type == self::TYPE_TITLE) {
31
            $label->setTextFont('RajdhaniMono');
32
        }
33
34
        return $label;
35
    }
36
}
37