Code Duplication    Length = 19-19 lines in 2 locations

src/View/Directives/AssetCssDirective.php 1 location

@@ 8-26 (lines=19) @@
5
use Roumen\Asset\Asset;
6
use Yajra\CMS\Repositories\FileAsset\FileAssetRepository;
7
8
class AssetCssDirective
9
{
10
    /**
11
     * Page header blade directive compiler.
12
     * @pageHeader($title, $description, $icon, $template)
13
     *
14
     * @param string|array $styles
15
     * @param null $category
16
     */
17
    public function handle($styles, $category = null)
18
    {
19
        foreach ((array)$styles as $style) {
20
            if (! str_contains('.css', $style)) {
21
                $style .= ".css";
22
            }
23
            Asset::add(app(FileAssetRepository::class)->getByName($style, $category)->url);
24
        }
25
    }
26
}

src/View/Directives/AssetJsDirective.php 1 location

@@ 8-26 (lines=19) @@
5
use Roumen\Asset\Asset;
6
use Yajra\CMS\Repositories\FileAsset\FileAssetRepository;
7
8
class AssetJsDirective
9
{
10
    /**
11
     * Page header blade directive compiler.
12
     * @pageHeader($title, $description, $icon, $template)
13
     *
14
     * @param string|array $scripts
15
     * @param null $category
16
     */
17
    public function handle($scripts, $category = null)
18
    {
19
        foreach ((array)$scripts as $script) {
20
            if (! str_contains('.js', $script)) {
21
                $script .= ".js";
22
            }
23
            Asset::add(app(FileAssetRepository::class)->getByName($script, $category)->url);
24
        }
25
    }
26
}