Completed
Push — develop ( 462b65...dca6d7 )
by Abdelrahman
06:01
created

Widget::list()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
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
    protected static function getFacadeAccessor()
14
    {
15
        return 'rinvex.widgets';
16
    }
17
18
    /**
19
     * Get the widgets collection.
20
     *
21
     * @return \Illuminate\Support\Collection
22
     */
23
    public static function list(): Collection
24
    {
25
        return app('rinvex.widgets.list');
26
    }
27
28
    /**
29
     * Get the widget groups collection.
30
     *
31
     * @return \Illuminate\Support\Collection
32
     */
33
    public static function groups(): Collection
34
    {
35
        return app('rinvex.widgets.group');
36
    }
37
38
    /**
39
     * Get the given group's widget collection.
40
     *
41
     * @param string $name
42
     *
43
     * @return \Rinvex\Widgets\Models\WidgetGroup
44
     */
45
    public static function group(string $name): WidgetGroup
46
    {
47
        return app('rinvex.widgets.group')->get($name)
48
               ?? app('rinvex.widgets.group')->put($name, new WidgetGroup())->get($name);
49
    }
50
}
51