CodeField   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 23
c 1
b 0
f 0
dl 0
loc 63
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A init() 0 29 2
1
<?php
2
/**
3
 * Code Field plugin for Craft CMS
4
 *
5
 * Provides a Code Field that has a full-featured code editor with syntax highlighting & autocomplete
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) 2022 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\codefield;
12
13
use Craft;
14
use craft\base\Plugin;
15
use craft\events\PluginEvent;
16
use craft\events\RegisterComponentTypesEvent;
17
use craft\services\Fields;
18
use craft\services\Plugins;
19
use nystudio107\codefield\fields\Code;
20
use yii\base\Event;
21
22
/**
23
 * Class CodeField
24
 *
25
 * @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...
26
 * @package   CodeField
0 ignored issues
show
Coding Style introduced by
Tag value for @package tag indented incorrectly; expected 1 spaces but found 3
Loading history...
27
 * @since     4.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...
28
 *
29
 */
0 ignored issues
show
Coding Style introduced by
Additional blank lines found at end of doc comment
Loading history...
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...
30
class CodeField extends Plugin
31
{
32
    // Static Properties
33
    // =========================================================================
34
35
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
36
     * @var CodeField
37
     */
38
    public static ?CodeField $plugin = null;
39
40
    // Public Properties
41
    // =========================================================================
42
43
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
44
     * @var string
45
     */
46
    public string $schemaVersion = '1.0.0';
47
48
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
49
     * @var bool
50
     */
51
    public bool $hasCpSettings = false;
52
53
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
54
     * @var bool
55
     */
56
    public bool $hasCpSection = false;
57
58
    // Public Methods
59
    // =========================================================================
60
61
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
62
     * @inheritdoc
63
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
64
    public function init()
65
    {
66
        parent::init();
67
        self::$plugin = $this;
68
69
        Event::on(
70
            Fields::class,
71
            Fields::EVENT_REGISTER_FIELD_TYPES,
72
            static function(RegisterComponentTypesEvent $event) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
73
                $event->types[] = Code::class;
74
            }
75
        );
76
77
        Event::on(
78
            Plugins::class,
79
            Plugins::EVENT_AFTER_INSTALL_PLUGIN,
80
            function(PluginEvent $event) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
81
                if ($event->plugin === $this) {
0 ignored issues
show
introduced by
The condition $event->plugin === $this is always false.
Loading history...
82
                }
83
            }
84
        );
85
86
        Craft::info(
87
            Craft::t(
88
                'codefield',
89
                '{name} plugin loaded',
90
                ['name' => $this->name]
91
            ),
92
            __METHOD__
93
        );
94
    }
95
}
96