Passed
Push — develop ( e22c82...346da8 )
by Andrew
04:14
created

ViteVariable   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 8
Bugs 0 Features 0
Metric Value
wmc 2
eloc 6
dl 0
loc 31
rs 10
c 8
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A includeCriticalCssTags() 0 4 1
A getCssHash() 0 4 1
1
<?php
2
/**
3
 * Vite plugin for Craft CMS 3.x
4
 *
5
 * Allows the use of the Vite.js next generation frontend tooling with Craft CMS
6
 *
7
 * @link      https://nystudio107.com
0 ignored issues
show
Coding Style introduced by
The tag in position 1 should be the @copyright tag
Loading history...
8
 * @copyright Copyright (c) 2021 nystudio107
0 ignored issues
show
Coding Style introduced by
@copyright tag must contain a year and the name of the copyright holder
Loading history...
9
 */
0 ignored issues
show
Coding Style introduced by
PHP version not specified
Loading history...
Coding Style introduced by
Missing @category tag in file comment
Loading history...
Coding Style introduced by
Missing @package tag in file comment
Loading history...
Coding Style introduced by
Missing @author tag in file comment
Loading history...
Coding Style introduced by
Missing @license tag in file comment
Loading history...
10
11
namespace nystudio107\vite\variables;
12
13
use nystudio107\vite\Vite;
14
15
use nystudio107\pluginvite\variables\ViteVariableInterface;
16
use nystudio107\pluginvite\variables\ViteVariableTrait;
17
18
use craft\helpers\Template;
19
20
use Twig\Error\LoaderError;
21
use Twig\Markup;
22
23
/**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
24
 * @author    nystudio107
0 ignored issues
show
Coding Style introduced by
Tag value for @author tag indented incorrectly; expected 2 spaces but found 4
Loading history...
Coding Style introduced by
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
Coding Style introduced by
The tag in position 1 should be the @package tag
Loading history...
25
 * @package   Vite
0 ignored issues
show
Coding Style introduced by
Tag value for @package tag indented incorrectly; expected 1 spaces but found 3
Loading history...
26
 * @since     1.0.5
0 ignored issues
show
Coding Style introduced by
The tag in position 3 should be the @author tag
Loading history...
Coding Style introduced by
Tag value for @since tag indented incorrectly; expected 3 spaces but found 5
Loading history...
27
 */
0 ignored issues
show
Coding Style introduced by
Missing @link tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @category tag in class comment
Loading history...
28
class ViteVariable implements ViteVariableInterface
29
{
30
    use ViteVariableTrait;
31
32
    /**
33
     * Returns the Critical CSS file for $template wrapped in <style></style>
34
     * tags
35
     *
36
     * @param null|string $name
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
37
     * @param array $attributes additional HTML key/value pair attributes to add to the resulting tag
0 ignored issues
show
Coding Style introduced by
Expected 7 spaces after parameter type; 1 found
Loading history...
38
     *
39
     * @return Markup
40
     * @throws LoaderError
41
     */
42
    public function includeCriticalCssTags($name = null, array $attributes = []): Markup
43
    {
44
        return Template::raw(
45
            Vite::$plugin->helper->getCriticalCssTags($name, $attributes) ?? ''
46
        );
47
    }
48
49
    /**
50
     * Return the hash value for the first CSS file bundled with the module specified via $path
51
     *
52
     * @param $path
0 ignored issues
show
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
Coding Style introduced by
Missing parameter comment
Loading history...
53
     * @return Markup
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
54
     */
55
    public function getCssHash($path): Markup
56
    {
57
        return Template::raw(
58
            Vite::$plugin->helper->getCssHash($path) ?? ''
59
        );
60
    }
61
}
62