Issues (413)

app/Services/Assets/Assets.php (2 issues)

1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: sheldon
5
 * Date: 18-4-2
6
 * Time: 上午10:06.
7
 */
8
9
namespace Yeelight\Services\Assets;
10
11
/**
12
 * Class Assets
13
 *
14
 * @category Yeelight
15
 *
16
 * @package Yeelight\Services\Assets
17
 *
18
 * @author Sheldon Lee <[email protected]>
19
 *
20
 * @license https://opensource.org/licenses/MIT MIT
21
 *
22
 * @link https://www.yeelight.com
23
 */
24
class Assets
25
{
26
    /**
27
     * $script
28
     *
29
     * @var array
30
     */
31
    public static $script = [];
32
33
    /**
34
     * $css
35
     *
36
     * @var array
37
     */
38
    public static $css = [];
39
40
    /**
41
     * $js
42
     *
43
     * @var array
44
     */
45
    public static $js = [];
46
47
    /**
48
     * Add css or get all css.
49
     *
50
     * @param null $css css
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $css is correct as it would always require null to be passed?
Loading history...
51
     *
52
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|void
53
     */
54
    public static function css($css = null)
55
    {
56
        if (!is_null($css)) {
57
            self::$css = array_merge(self::$css, (array) $css);
58
59
            return;
60
        }
61
62
        return view('backend.partials.css', ['css' => array_unique(static::$css)]);
63
    }
64
65
    /**
66
     * Add js or get all js.
67
     *
68
     * @param null $js
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $js is correct as it would always require null to be passed?
Loading history...
69
     *
70
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|void
71
     */
72
    public static function js($js = null)
73
    {
74
        if (!is_null($js)) {
75
            self::$js = array_merge(self::$js, (array) $js);
76
77
            return;
78
        }
79
80
        return view('backend.partials.js', ['js' => array_unique(static::$js)]);
81
    }
82
83
    /**
84
     * @param string $script
85
     *
86
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|void
87
     */
88
    public static function script($script = '')
89
    {
90
        if (!empty($script)) {
91
            self::$script = array_merge(self::$script, (array) $script);
92
93
            return;
94
        }
95
96
        return view('backend.partials.script', ['script' => array_unique(self::$script)]);
97
    }
98
}
99