ViteVariable   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 10
Bugs 0 Features 0
Metric Value
wmc 3
eloc 8
c 10
b 0
f 0
dl 0
loc 47
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A includeCriticalCssTags() 0 4 1
A getCssInlineTags() 0 4 1
A getCssHash() 0 4 1
1
<?php
2
/**
3
 * Vite plugin for Craft CMS
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 craft\helpers\Template;
14
use nystudio107\pluginvite\variables\ViteVariableInterface;
15
use nystudio107\pluginvite\variables\ViteVariableTrait;
16
use nystudio107\vite\Vite;
17
use Twig\Error\LoaderError;
18
use Twig\Markup;
19
20
/**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
21
 * @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...
22
 * @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...
23
 * @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...
24
 */
0 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
25
class ViteVariable implements ViteVariableInterface
26
{
27
    use ViteVariableTrait;
28
29
    /**
30
     * Returns the Critical CSS file for $template wrapped in <style></style>
31
     * tags
32
     *
33
     * @param null|string $name
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
34
     * @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...
35
     *
36
     * @return Markup
37
     * @throws LoaderError
38
     */
39
    public function includeCriticalCssTags(?string $name = null, array $attributes = []): Markup
40
    {
41
        return Template::raw(
42
            Vite::$plugin->helper->getCriticalCssTags($name, $attributes)
0 ignored issues
show
Bug introduced by
The method getCriticalCssTags() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

42
            Vite::$plugin->helper->/** @scrutinizer ignore-call */ 
43
                                   getCriticalCssTags($name, $attributes)

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
43
        );
44
    }
45
46
    /**
47
     * Returns the passed in CSS file at the specified file system path or URL, wrapped in
48
     * <style></style> tags
49
     *
50
     * @param string $path
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
51
     * @param array $attributes additional HTML key/value pair attributes to add to the resulting tag
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
52
     *
53
     * @return string
54
     */
55
    public function getCssInlineTags(string $path, array $attributes = []): string
56
    {
57
        return Template::raw(
58
            Vite::$plugin->helper->getCssInlineTags($path, $attributes)
59
        );
60
    }
61
62
    /**
63
     * Return the hash value for the first CSS file bundled with the module specified via $path
64
     *
65
     * @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...
66
     * @return Markup
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
67
     */
68
    public function getCssHash($path): Markup
69
    {
70
        return Template::raw(
71
            Vite::$plugin->helper->getCssHash($path)
72
        );
73
    }
74
}
75