Settings   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 97
Duplicated Lines 0 %

Importance

Changes 7
Bugs 0 Features 0
Metric Value
eloc 32
c 7
b 0
f 0
dl 0
loc 97
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A rules() 0 17 1
1
<?php
2
/**
3
 * Twigpack plugin for Craft CMS 3.x
4
 *
5
 * Twigpack is the conduit between Twig and webpack, with manifest.json &
6
 * webpack-dev-server HMR support
7
 *
8
 * @link      https://nystudio107.com/
0 ignored issues
show
Coding Style introduced by
The tag in position 1 should be the @copyright tag
Loading history...
9
 * @copyright Copyright (c) 2018 nystudio107
0 ignored issues
show
Coding Style introduced by
@copyright tag must contain a year and the name of the copyright holder
Loading history...
10
 */
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...
11
12
namespace nystudio107\twigpack\models;
13
14
use craft\base\Model;
15
16
/**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
17
 * @author    nystudio107
0 ignored issues
show
Coding Style introduced by
The tag in position 1 should be the @package tag
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
Tag value for @author tag indented incorrectly; expected 2 spaces but found 4
Loading history...
18
 * @package   Twigpack
0 ignored issues
show
Coding Style introduced by
Tag value for @package tag indented incorrectly; expected 1 spaces but found 3
Loading history...
19
 * @since     1.0.0
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...
20
 */
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...
21
class Settings extends Model
22
{
23
    // Public Properties
24
    // =========================================================================
25
26
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
27
     * @var bool If `devMode` is on, use webpack-dev-server to all for HMR (hot
28
     *      module reloading)
29
     */
30
    public bool $useDevServer = true;
31
32
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
33
     * @var bool If true, enforces Absolute Urls, if false, allows relative
34
     */
35
    public bool $useAbsoluteUrl = true;
36
37
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
38
     * @var array|string The JavaScript entry from the manifest.json to inject on
39
     *      Twig error pages
40
     */
41
    public array|string $errorEntry = '';
42
43
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
44
     * @var string String to be appended to the cache key
45
     */
46
    public string $cacheKeySuffix = '';
47
48
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
49
     * @var array Manifest file names
50
     */
51
    public array $manifest = [
52
        'legacy' => 'manifest-legacy.json',
53
        'modern' => 'manifest.json',
54
    ];
55
56
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
57
     * @var array Public server config
58
     */
59
    public array $server = [
60
        'manifestPath' => '/',
61
        'publicPath' => '/',
62
    ];
63
64
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
65
     * @var array webpack-dev-server config
66
     */
67
    public array $devServer = [
68
        'manifestPath' => 'http://localhost:8080/',
69
        'publicPath' => 'http://localhost:8080/',
70
    ];
71
72
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
73
     * @var string defines which bundle will be used from the webpack dev server.
74
     *      Can be 'modern', 'legacy' or 'combined'. Defaults to 'modern'.
75
     */
76
    public string $devServerBuildType = 'modern';
77
78
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
79
     * @var string Whether to include a Content Security Policy "nonce" for inline
80
     *      CSS or JavaScript. Valid values are 'header' or 'tag' for how the CSP
81
     *      should be included. c.f.:
82
     *      https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src#Unsafe_inline_script
83
     */
84
    public string $cspNonce = '';
85
86
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
87
     * @var array Local files config
88
     */
89
    public array $localFiles = [
90
        'basePath' => '@webroot/',
91
        'criticalPrefix' => 'dist/criticalcss/',
92
        'criticalSuffix' => '_critical.min.css',
93
    ];
94
95
    // Public Methods
96
    // =========================================================================
97
98
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
99
     * @inheritdoc
100
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
101
    public function rules(): array
102
    {
103
        return [
104
            ['useDevServer', 'boolean'],
105
            ['useDevServer', 'default', 'value' => true],
106
            ['errorEntry', 'string'],
107
            ['devServerBuildType', 'string'],
108
            ['cspNonce', 'string'],
109
            [
110
                [
111
                    'manifest',
112
                    'server',
113
                    'devServer',
114
                    'localFiles',
115
                ],
116
                'each',
117
                'rule' => ['string'],
118
            ],
119
        ];
120
    }
121
}
122