Passed
Push — v3 ( f9f18d...456560 )
by Andrew
29:02 queued 19:33
created

ManifestVariable::includeSafariNomoduleFix()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 2
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 2
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace nystudio107\retour\variables;
4
5
use nystudio107\retour\helpers\Manifest as ManifestHelper;
6
7
use craft\helpers\Template;
8
9
use yii\base\InvalidConfigException;
10
use yii\web\NotFoundHttpException;
11
12
use Twig\Markup;
13
14
class ManifestVariable
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class ManifestVariable
Loading history...
15
{
16
    // Public Methods
17
    // =========================================================================
18
19
    /**
20
     * Get the passed in JS modules from the manifest, and register them in the current Craft view
21
     *
22
     * @param array $modules
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
23
     * @throws InvalidConfigException
0 ignored issues
show
Coding Style introduced by
Tag @throws cannot be grouped with parameter tags in a doc comment
Loading history...
24
     * @throws NotFoundHttpException
0 ignored issues
show
Coding Style introduced by
Tag @throws cannot be grouped with parameter tags in a doc comment
Loading history...
25
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
26
    public function registerJsModules(array $modules)
27
    {
28
        ManifestHelper::registerJsModules($modules);
29
    }
30
31
    /**
32
     * Get the passed in CS modules from the manifest, and register them in the current Craft view
33
     *
34
     * @param array $modules
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
35
     * @throws InvalidConfigException
0 ignored issues
show
Coding Style introduced by
Tag @throws cannot be grouped with parameter tags in a doc comment
Loading history...
36
     * @throws NotFoundHttpException
0 ignored issues
show
Coding Style introduced by
Tag @throws cannot be grouped with parameter tags in a doc comment
Loading history...
37
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
38
    public function registerCssModules(array $modules)
39
    {
40
        ManifestHelper::registerCssModules($modules);
41
    }
42
43
    /**
44
     * Get the passed in JS module from the manifest, then output a `<script src="">` tag for it in the HTML
45
     *
46
     * @param string     $moduleName
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 5 found
Loading history...
47
     * @param bool       $async
0 ignored issues
show
Coding Style introduced by
Expected 3 spaces after parameter type; 7 found
Loading history...
Coding Style introduced by
Missing parameter comment
Loading history...
48
     *
49
     * @return null|Markup
50
     * @throws NotFoundHttpException
51
     */
52
    public function includeJsModule(string $moduleName, bool $async = false)
53
    {
54
        return Template::raw(
55
            ManifestHelper::includeJsModule($moduleName, $async) ?? ''
56
        );
57
    }
58
59
    /**
60
     * Get the passed in CS module from the manifest, then output a `<link>` tag for it in the HTML
61
     *
62
     * @param string     $moduleName
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 5 found
Loading history...
63
     * @param bool       $async
0 ignored issues
show
Coding Style introduced by
Expected 3 spaces after parameter type; 7 found
Loading history...
Coding Style introduced by
Missing parameter comment
Loading history...
64
     *
65
     * @return Markup
66
     * @throws NotFoundHttpException
67
     */
68
    public function includeCssModule(string $moduleName, bool $async = false): Markup
69
    {
70
        return Template::raw(
71
            ManifestHelper::includeCssModule($moduleName, $async) ?? ''
72
        );
73
    }
74
}
75