Ignition::scripts()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Facade\Ignition;
4
5
use Closure;
6
use Facade\Ignition\Tabs\Tab;
7
8
class Ignition
9
{
10
    /** @var Closure[] */
11
    public static $callBeforeShowingErrorPage = [];
12
13
    /** @var array */
14
    public static $tabs = [];
15
16
    public static function tab(Tab $tab)
17
    {
18
        static::$tabs[] = $tab;
19
    }
20
21
    public static function styles(): array
22
    {
23
        return collect(static::$tabs)->flatMap(function ($tab) {
24
            return $tab->styles;
25
        })
26
            ->unique()
27
            ->toArray();
28
    }
29
30
    public static function scripts(): array
31
    {
32
        return collect(static::$tabs)->flatMap(function ($tab) {
33
            return $tab->scripts;
34
        })
35
            ->unique()
36
            ->toArray();
37
    }
38
39
    public static function registerAssets(Closure $callable)
40
    {
41
        static::$callBeforeShowingErrorPage[] = $callable;
42
    }
43
}
44