Completed
Push — master ( c8d3eb...7bdd8d )
by Oleg
03:59
created

TextFactory::serialize()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 9
Ratio 100 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 9
loc 9
ccs 4
cts 4
cp 1
rs 9.6666
cc 2
eloc 5
nc 2
nop 0
crap 2
1
<?php
2
namespace Malezha\Menu\Factory;
3
4
use Illuminate\Contracts\Container\Container;
5
use Malezha\Menu\Contracts\Attributes;
6
use Malezha\Menu\Element\Text;
7
8
/**
9
 * Class TextFactory
10
 * @package Malezha\Menu\Factory
11
 * 
12
 * @property string $text
13
 * @property Attributes $attributes
14
 * @property mixed $displayRule
15
 */
16
class TextFactory extends AbstractElementFactory
17
{
18
    /**
19
     * @param array $parameters
20
     * @return Text
21
     */
22 7
    public function build($parameters = [])
23
    {
24 7
        $text = $this->app->make(Text::class, $this->mergeParameters($parameters));
25 7
        if (array_key_exists('displayRule', $this->parameters)) {
26 7
            $text->setDisplayRule($this->parameters['displayRule']);
27
        }
28
29 7
        return $text;
30
    }
31
32
    /**
33
     * @inheritDoc
34
     */
35 10
    public function __construct(Container $container)
36
    {
37 10
        parent::__construct($container);
38
        
39 10
        $this->parameters = [
40 10
            'text' => null,
41
            'displayRule' => true,
42 10
            'attributes' => $this->app->make(Attributes::class, ['attributes' => []]),
43 10
            'view' => $this->getElementConfig(Text::class)['view'],
44
        ];
45
    }
46
}