Widget   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 45
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 2

4 Methods

Rating   Name   Duplication   Size   Complexity  
A list() 0 4 1
A groups() 0 4 1
A group() 0 5 1
A getFacadeAccessor() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Rinvex\Widgets\Facades;
6
7
use Illuminate\Support\Collection;
8
use Illuminate\Support\Facades\Facade;
9
use Rinvex\Widgets\Models\WidgetGroup;
10
11
class Widget extends Facade
12
{
13
    /**
14
     * Get the registered name of the component.
15
     *
16
     * @return string
17
     */
18
    protected static function getFacadeAccessor()
19
    {
20
        return 'rinvex.widgets';
21
    }
22
23
    /**
24
     * Get the widgets collection.
25
     *
26
     * @return \Illuminate\Support\Collection
27
     */
28
    public static function list(): Collection
29
    {
30
        return app('rinvex.widgets.list');
31
    }
32
33
    /**
34
     * Get the widget groups collection.
35
     *
36
     * @return \Illuminate\Support\Collection
37
     */
38
    public static function groups(): Collection
39
    {
40
        return app('rinvex.widgets.group');
41
    }
42
43
    /**
44
     * Get the given group's widget collection.
45
     *
46
     * @param string $name
47
     *
48
     * @return \Rinvex\Widgets\Models\WidgetGroup
49
     */
50
    public static function group(string $name): WidgetGroup
51
    {
52
        return app('rinvex.widgets.group')->get($name)
53
               ?? app('rinvex.widgets.group')->put($name, new WidgetGroup())->get($name);
54
    }
55
}
56