Issues (134)

src/ICalendar.php (34 issues)

1
<?php
2
/**
3
 * iCalendar plugin for Craft CMS 3.x
0 ignored issues
show
Doc comment short description must start with a capital letter
Loading history...
4
 *
5
 * Tools for parsing & formatting the RFC 2445 iCalendar (.ics) specification
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) 2018 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\icalendar;
12
13
use Craft;
14
use craft\base\Plugin;
15
use craft\web\twig\variables\CraftVariable;
16
use nystudio107\icalendar\services\Convert as ConvertService;
17
use nystudio107\icalendar\services\Parse as ParseService;
18
use nystudio107\icalendar\twigextensions\ICalendarTwigExtension;
19
use nystudio107\icalendar\variables\ICalendarVariable;
20
use yii\base\Event;
21
22
/**
23
 * Class ICalendar
24
 *
25
 * @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...
26
 * @package   ICalendar
0 ignored issues
show
Tag value for @package tag indented incorrectly; expected 1 spaces but found 3
Loading history...
27
 * @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...
28
 *
29
 * @property  ConvertService $convert
0 ignored issues
show
Tag value for @property tag indented incorrectly; expected 1 spaces but found 2
Loading history...
30
 * @property  ParseService $parse
0 ignored issues
show
Tag value for @property tag indented incorrectly; expected 1 spaces but found 2
Loading history...
31
 */
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...
32
class ICalendar extends Plugin
33
{
34
    // Static Properties
35
    // =========================================================================
36
37
    /**
0 ignored issues
show
Missing short description in doc comment
Loading history...
38
     * @var ?ICalendar
39
     */
40
    public static ?ICalendar $plugin = null;
41
42
    /**
0 ignored issues
show
Missing short description in doc comment
Loading history...
43
     * @var ?ICalendarVariable
44
     */
45
    public static ?ICalendarVariable $variable = null;
46
47
    // Public Properties
48
    // =========================================================================
49
50
    /**
0 ignored issues
show
Missing short description in doc comment
Loading history...
51
     * @var string
52
     */
53
    public string $schemaVersion = '1.0.0';
54
55
    /**
0 ignored issues
show
Missing short description in doc comment
Loading history...
56
     * @var bool
57
     */
58
    public bool $hasCpSection = false;
59
60
    /**
0 ignored issues
show
Missing short description in doc comment
Loading history...
61
     * @var bool
62
     */
63
    public bool $hasCpSettings = false;
64
65
    // Public Methods
66
    // =========================================================================
67
68
    /**
0 ignored issues
show
Missing short description in doc comment
Loading history...
Parameter $id should have a doc-comment as per coding-style.
Loading history...
Parameter $parent should have a doc-comment as per coding-style.
Loading history...
Parameter $config should have a doc-comment as per coding-style.
Loading history...
69
     * @inheritdoc
70
     */
71
    public function __construct($id, $parent = null, array $config = [])
72
    {
73
        $config['components'] = [
74
            'convert' => ConvertService::class,
75
            'parse' => ParseService::class,
76
        ];
77
78
        parent::__construct($id, $parent, $config);
79
    }
80
81
    /**
0 ignored issues
show
Missing short description in doc comment
Loading history...
82
     * @inheritdoc
83
     */
0 ignored issues
show
Missing @return tag in function comment
Loading history...
84
    public function init(): void
85
    {
86
        parent::init();
87
        self::$plugin = $this;
88
        self::$variable = new ICalendarVariable();
89
        // Register Twig extension
90
        Craft::$app->view->registerTwigExtension(new ICalendarTwigExtension());
91
        // Register variable
92
        Event::on(
93
            CraftVariable::class,
94
            CraftVariable::EVENT_INIT,
95
            static function(Event $event) {
0 ignored issues
show
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
96
                /** @var CraftVariable $variable */
0 ignored issues
show
The open comment tag must be the only content on the line
Loading history...
Missing short description in doc comment
Loading history...
The close comment tag must be the only content on the line
Loading history...
97
                $variable = $event->sender;
98
                $variable->set('icalendar', self::$variable);
99
            }
100
        );
101
102
        Craft::info(
103
            Craft::t(
104
                'icalendar',
105
                '{name} plugin loaded',
106
                ['name' => $this->name]
107
            ),
108
            __METHOD__
109
        );
110
    }
111
112
    // Protected Methods
113
    // =========================================================================
114
}
115