Completed
Push — master ( c4a686...2e0334 )
by Arjay
11:39
created

AssetCssDirective::handle()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 9
Ratio 100 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 3
eloc 5
c 2
b 0
f 0
nc 3
nop 2
dl 9
loc 9
rs 9.6666
1
<?php
2
3
namespace Yajra\CMS\View\Directives;
4
5
use Roumen\Asset\Asset;
6
use Yajra\CMS\Repositories\FileAsset\FileAssetRepository;
7
8 View Code Duplication
class AssetCssDirective
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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
}