FrontMatter   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 18
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A init() 0 13 1
1
<?php
2
/**
3
 * @link https://www.github.com/tinydots/craft-front-matter
4
 * @copyright Copyright (c) Mike Pepper
5
 * @license MIT
6
 */
7
8
namespace tinydots\frontmatter;
9
10
use tinydots\frontmatter\services\FrontMatterService;
11
use tinydots\frontmatter\variables\FrontMatterVariable;
12
use craft\base\Plugin;
13
use craft\web\twig\variables\CraftVariable;
14
use yii\base\Event;
15
16
/**
17
 * Class FrontMatter
18
 *
19
 * @property FrontMatterService $frontMatter
20
 * @author Mike Pepper <[email protected]>
21
 * @since 1.0.0
22
 */
23
class FrontMatter extends Plugin
24
{
25
    /** @var FrontMatter */
26
    public static $plugin;
27
28 3
    public function init()
29
    {
30 3
        parent::init();
31
32 3
        self::$plugin = $this;
33
34 3
        $this->setComponents([
35 3
            'frontMatter' => FrontMatterService::class,
36
        ]);
37
38
        Event::on(CraftVariable::class, CraftVariable::EVENT_INIT, function(Event $event) {
39 1
            $variable = $event->sender;
40 1
            $variable->set('frontMatter', FrontMatterVariable::class);
41 3
        });
42
    }
43
}