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

LinkFactory::setDisplayRule()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
cc 2
eloc 3
nc 2
nop 1
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\Link;
7
8
/**
9
 * Class LinkFactory
10
 * @package Malezha\Menu\Factory
11
 *
12
 * @property string $title
13
 * @property string $url
14
 * @property Attributes $attributes
15
 * @property Attributes $activeAttributes
16
 * @property Attributes $linkAttributes
17
 * @property string $view
18
 * @property mixed $displayRule
19
 *
20
 */
21
class LinkFactory extends AbstractElementFactory
22
{
23
    /**
24
     * @inheritdoc
25
     */
26 25
    public function __construct(Container $container)
27
    {
28 25
        parent::__construct($container);
29
        
30 25
        $this->parameters = [
31 25
            'title' => '',
32 25
            'url' => '#',
33 25
            'attributes' => $this->app->make(Attributes::class, ['attributes' => []]),
34 25
            'activeAttributes' => $this->app->make(Attributes::class, ['attributes' => []]),
35 25
            'linkAttributes' => $this->app->make(Attributes::class, ['attributes' => []]),
36 25
            'view' => $this->getElementConfig(Link::class)['view'],
37
            'displayRule' => true,
38
        ];
39 25
    }
40
41
    /**
42
     * @param array $parameters
43
     * @return Link
44
     */
45 14
    public function build($parameters = [])
46
    {
47 14
        $link = $this->app->make(Link::class, $this->mergeParameters($parameters));
48 14
        $this->setDisplayRule($link);
49
        
50 14
        return $link;
51
    }
52
}