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

SubMenuFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 12
ccs 9
cts 9
cp 1
rs 9.4285
cc 1
eloc 8
nc 1
nop 1
crap 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\Contracts\Builder;
7
use Malezha\Menu\Element\SubMenu;
8
9
/**
10
 * Class SubMenuFactory
11
 * @package Malezha\Menu\Factory
12
 * 
13
 * @property Builder $builder
14
 * @inheritdoc
15
 */
16
class SubMenuFactory extends LinkFactory
17
{
18 7
    public function __construct(Container $container)
19
    {
20 7
        parent::__construct($container);
21
22 7
        $this->parameters['builder'] = $this->app->make(Builder::class, [
23 7
            'container' => $this->app,
24 7
            'name' => 'submenu-' . spl_object_hash($this),
25 7
            'activeAttributes' => $this->app->make(Attributes::class, ['attributes' => []]),
26 7
            'attributes' => $this->app->make(Attributes::class, ['attributes' => []]),
27
        ]);
28 7
        $this->parameters['view'] = $this->getElementConfig(SubMenu::class)['view'];
29 7
    }
30
31
    /**
32
     * @param array $parameters
33
     * @return SubMenu
34
     */
35 7
    public function build($parameters = [])
36
    {
37 7
        $subMenu = $this->app->make(SubMenu::class, $this->mergeParameters($parameters));
38 7
        $this->setDisplayRule($subMenu);
39
        
40 7
        return $subMenu;
41
    }
42
}