Passed
Push — develop-v4 ( 87c832...2540cb )
by Andrew
18:10
created

Plugin::blitzWarmingActive()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 10
rs 10
cc 3
nc 3
nop 0
1
<?php
2
/**
3
 * ImageOptimize plugin for Craft CMS
4
 *
5
 * Automatically optimize images after they've been transformed
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) 2023 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\imageoptimize\helpers;
12
13
use Craft;
14
use putyourlightson\blitz\Blitz;
0 ignored issues
show
Bug introduced by
The type putyourlightson\blitz\Blitz was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
16
/**
17
 * ImageOptimize Settings model
18
 *
19
 * @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...
20
 * @package   ImageOptimize
0 ignored issues
show
Coding Style introduced by
Tag value for @package tag indented incorrectly; expected 1 spaces but found 3
Loading history...
21
 * @since     4.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...
22
 */
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...
23
class Plugin
24
{
25
    // Constants
26
    // =========================================================================
27
28
    public const BLITZ_PLUGIN_HANDLE = 'blitz';
29
30
    // Public Static Methods
31
    // =========================================================================
32
33
    /**
34
     * Determine if the Blitz plugin is installed, and if cache warming is enabled
35
     *
36
     * @return bool
37
     */
38
    public static function blitzWarmingActive(): bool
39
    {
40
        /** @var Blitz $blitzPlugin */
0 ignored issues
show
Coding Style introduced by
The open comment tag must be the only content on the line
Loading history...
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
The close comment tag must be the only content on the line
Loading history...
41
        $blitzPlugin = Craft::$app->getPlugins()->getPlugin(self::BLITZ_PLUGIN_HANDLE);
42
        if (!$blitzPlugin) {
0 ignored issues
show
introduced by
$blitzPlugin is of type putyourlightson\blitz\Blitz, thus it always evaluated to true.
Loading history...
43
            return false;
44
        }
45
        $blitzSettings = $blitzPlugin::$plugin->settings;
46
47
        return $blitzSettings->cachingEnabled && $blitzSettings->warmCacheAutomatically;
48
    }
49
}
50