Passed
Push — develop ( e0632b...35bdc8 )
by Andrew
21:02
created

ManifestVariable   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Importance

Changes 5
Bugs 0 Features 0
Metric Value
wmc 4
eloc 7
c 5
b 0
f 0
dl 0
loc 60
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A registerCssModules() 0 3 1
A includeJsModule() 0 4 1
A includeCssModule() 0 4 1
A registerJsModules() 0 3 1
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace nystudio107\instantanalytics\variables;
4
5
use nystudio107\instantanalytics\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...
47
     * @param bool       $async
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
48
     * @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...
49
     *
50
     * @return null|Markup
51
     * @throws NotFoundHttpException
52
     */
53
    public function includeJsModule(string $moduleName, bool $async = false)
54
    {
55
        return Template::raw(
56
            ManifestHelper::includeJsModule($moduleName, $async) ?? ''
57
        );
58
    }
59
60
    /**
61
     * Get the passed in CS module from the manifest, then output a `<link>` tag for it in the HTML
62
     *
63
     * @param string     $moduleName
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
64
     * @param bool       $async
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
65
     * @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...
66
     *
67
     * @return Markup
68
     * @throws NotFoundHttpException
69
     */
70
    public function includeCssModule(string $moduleName, bool $async = false): Markup
71
    {
72
        return Template::raw(
73
            ManifestHelper::includeCssModule($moduleName, $async) ?? ''
74
        );
75
    }
76
}
77