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

SubMenuFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 1
A build() 0 7 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
}