LaravelMenuRenderFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 3 1
A addRender() 0 3 1
1
<?php
2
3
namespace Adelf\LaravelMenu;
4
5
use Adelf\LaravelMenu\Renders\LaravelMenuRender;
6
7
final class LaravelMenuRenderFactory
8
{
9
    /**
10
     * @var array
11
     */
12
    private static $filters = [];
13
14
    /**
15
     * @param string $name
16
     * @param string | LaravelMenuRender $renderer class name or object - LaravelMenuRenderer instance
17
     */
18
    public static function addRender(string $name, $renderer)
19
    {
20
        self::$filters[$name] = $renderer;
21
    }
22
23
    /**
24
     * @param string $name
25
     * @return LaravelMenuRender
26
     */
27
    public function create(string $name): LaravelMenuRender
28
    {
29
        return app(self::$filters[$name]);
0 ignored issues
show
Bug Best Practice introduced by
The expression return app(self::filters[$name]) could return the type Illuminate\Foundation\Application which is incompatible with the type-hinted return Adelf\LaravelMenu\Renders\LaravelMenuRender. Consider adding an additional type-check to rule them out.
Loading history...
30
    }
31
}