Typogrify   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 80
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 24
c 3
b 0
f 0
dl 0
loc 80
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createSettingsModel() 0 3 1
A init() 0 25 1
1
<?php
2
/**
3
 * Typogrify plugin for Craft CMS
4
 *
5
 * Typogrify prettifies your web typography by preventing ugly quotes and 'widows' and more
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) 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\typogrify;
12
13
use Craft;
14
use craft\base\Model;
15
use craft\base\Plugin;
16
use craft\web\twig\variables\CraftVariable;
17
use nystudio107\typogrify\models\Settings;
18
use nystudio107\typogrify\services\ServicesTrait;
19
use nystudio107\typogrify\twigextensions\TypogrifyTwigExtension;
20
use nystudio107\typogrify\variables\TypogrifyVariable;
21
use yii\base\Event;
22
23
/**
24
 * Class Typogrify
25
 *
26
 * @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...
27
 * @package   Typogrify
0 ignored issues
show
Coding Style introduced by
Tag value for @package tag indented incorrectly; expected 1 spaces but found 3
Loading history...
28
 * @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...
29
 *
30
 * @property  Settings $settings
0 ignored issues
show
Coding Style introduced by
Tag value for @property tag indented incorrectly; expected 1 spaces but found 2
Loading history...
31
 */
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...
32
class Typogrify extends Plugin
33
{
34
    // Traits
35
    // =========================================================================
36
37
    use ServicesTrait;
38
39
    // Static Properties
40
    // =========================================================================
41
42
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
43
     * @var ?Typogrify
44
     */
45
    public static ?Typogrify $plugin = null;
46
47
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
48
     * @var ?TypogrifyVariable
49
     */
50
    public static ?TypogrifyVariable $variable = null;
51
52
    // Public Properties
53
    // =========================================================================
54
55
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
56
     * @var string
57
     */
58
    public string $schemaVersion = '1.0.0';
59
60
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
61
     * @var bool
62
     */
63
    public bool $hasCpSettings = false;
64
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
65
     * @var bool
66
     */
67
    public bool $hasCpSection = false;
68
69
    // Public Methods
70
    // =========================================================================
71
72
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
73
     * @inheritdoc
74
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
75
    public function init(): void
76
    {
77
        parent::init();
78
        self::$plugin = $this;
79
        self::$variable = new TypogrifyVariable();
80
81
        Craft::$app->view->registerTwigExtension(new TypogrifyTwigExtension());
82
        // Register our variables
83
        Event::on(
84
            CraftVariable::class,
85
            CraftVariable::EVENT_INIT,
86
            static function(Event $event) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
87
                /** @var CraftVariable $variable */
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...
88
                $variable = $event->sender;
89
                $variable->set('typogrify', self::$variable);
90
            }
91
        );
92
93
        Craft::info(
94
            Craft::t(
95
                'typogrify',
96
                '{name} plugin loaded',
97
                ['name' => $this->name]
98
            ),
99
            __METHOD__
100
        );
101
    }
102
103
    // Protected Methods
104
    // =========================================================================
105
106
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
107
     * @inheritdoc
108
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
109
    protected function createSettingsModel(): ?Model
110
    {
111
        return new Settings();
112
    }
113
}
114