LaravelMenuRenderFactory::addRender()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
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
}