Passed
Push — develop ( 793d0f...5fa866 )
by Andrew
20:45
created

ManifestVariable::getModuleUri()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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