Issues (1497)

src/utilities/ImageOptimizeUtility.php (27 issues)

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
The tag in position 1 should be the @copyright tag
Loading history...
8
 * @copyright Copyright (c) 2020 nystudio107
0 ignored issues
show
@copyright tag must contain a year and the name of the copyright holder
Loading history...
9
 */
0 ignored issues
show
PHP version not specified
Loading history...
Missing @category tag in file comment
Loading history...
Missing @package tag in file comment
Loading history...
Missing @author tag in file comment
Loading history...
Missing @license tag in file comment
Loading history...
10
11
namespace nystudio107\imageoptimize\utilities;
12
13
use Craft;
14
15
use craft\base\Utility;
16
use nystudio107\imageoptimize\ImageOptimize;
17
18
/**
19
 * ImageOptimize Utility
20
 *
21
 * @author    nystudio107
0 ignored issues
show
The tag in position 1 should be the @package tag
Loading history...
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
Tag value for @author tag indented incorrectly; expected 2 spaces but found 4
Loading history...
22
 * @package   ImageOptimize
0 ignored issues
show
Tag value for @package tag indented incorrectly; expected 1 spaces but found 3
Loading history...
23
 * @since     1.0.0
0 ignored issues
show
The tag in position 3 should be the @author tag
Loading history...
Tag value for @since tag indented incorrectly; expected 3 spaces but found 5
Loading history...
24
 */
0 ignored issues
show
Missing @category tag in class comment
Loading history...
Missing @license tag in class comment
Loading history...
Missing @link tag in class comment
Loading history...
25
class ImageOptimizeUtility extends Utility
26
{
27
    // Static
28
    // =========================================================================
29
30
    /**
0 ignored issues
show
Missing short description in doc comment
Loading history...
31
     * @inheritdoc
32
     */
0 ignored issues
show
Missing @return tag in function comment
Loading history...
33
    public static function displayName(): string
34
    {
35
        return Craft::t('image-optimize', 'ImageOptimize Info');
36
    }
37
38
    /**
0 ignored issues
show
Missing short description in doc comment
Loading history...
39
     * @inheritdoc
40
     */
0 ignored issues
show
Missing @return tag in function comment
Loading history...
41
    public static function id(): string
42
    {
43
        return 'imageoptimize-image-optimize-utility';
44
    }
45
46
    /**
0 ignored issues
show
Missing short description in doc comment
Loading history...
47
     * @inheritdoc
48
     */
0 ignored issues
show
Missing @return tag in function comment
Loading history...
49
    public static function iconPath(): ?string
50
    {
51
        return Craft::getAlias("@nystudio107/imageoptimize/icon-mask.svg");
0 ignored issues
show
Bug Best Practice introduced by
The expression return Craft::getAlias('...ptimize/icon-mask.svg') could return the type false which is incompatible with the type-hinted return null|string. Consider adding an additional type-check to rule them out.
Loading history...
52
    }
53
54
    /**
0 ignored issues
show
Missing short description in doc comment
Loading history...
55
     * @inheritdoc
56
     */
0 ignored issues
show
Missing @return tag in function comment
Loading history...
57
    public static function badgeCount(): int
58
    {
59
        return 0;
60
    }
61
62
    /**
0 ignored issues
show
Missing short description in doc comment
Loading history...
63
     * @inheritdoc
64
     */
0 ignored issues
show
Missing @return tag in function comment
Loading history...
65
    public static function contentHtml(): string
66
    {
67
        $imageProcessors = ImageOptimize::$plugin->optimize->getActiveImageProcessors();
68
        $variantCreators = ImageOptimize::$plugin->optimize->getActiveVariantCreators();
69
70
        return Craft::$app->getView()->renderTemplate(
71
            'image-optimize/_components/utilities/ImageOptimizeUtility_content',
72
            [
73
                'imageProcessors' => $imageProcessors,
74
                'variantCreators' => $variantCreators,
75
            ]
76
        );
77
    }
78
}
79