Completed
Push — master ( e84808...5a9d2e )
by Oleg
07:58
created

TextFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 31
ccs 12
cts 12
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A build() 0 9 2
A __construct() 0 11 1
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 6
    public function build($parameters = [])
23
    {
24 6
        $text = $this->app->make(Text::class, $this->mergeParameters($parameters));
25 6
        if (array_key_exists('displayRule', $this->parameters)) {
26 6
            $text->setDisplayRule($this->parameters['displayRule']);
27
        }
28
29 6
        return $text;
30
    }
31
32
    /**
33
     * @inheritDoc
34
     */
35 6
    public function __construct(Container $container)
36
    {
37 6
        parent::__construct($container);
38
        
39 6
        $this->parameters = [
40 6
            'text' => null,
41
            'displayRule' => true,
42 6
            'attributes' => $this->app->make(Attributes::class, ['attributes' => []]),
43 6
            'view' => $this->getElementConfig(Text::class)['view'],
44
        ];
45
    }
46
}