Completed
Push — develop ( 9d1308...acfebe )
by Nate
12:26
created

Flux::getLogFileName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://flipboxfactory.com/software/flux/license
6
 * @link       https://www.flipboxfactory.com/software/flux/
7
 */
8
9
namespace flipbox\flux;
10
11
use craft\base\Plugin;
12
use craft\web\twig\variables\CraftVariable;
13
use flipbox\ember\modules\LoggerTrait;
14
use yii\base\Event;
15
16
/**
17
 * @author Flipbox Factory <[email protected]>
18
 * @since 1.0.0
19
 *
20
 * @property services\Transformers $transformers
21
 */
22
class Flux extends Plugin
23
{
24
    use LoggerTrait;
25
26
    /**
27
     * The global scope
28
     */
29
    const GLOBAL_SCOPE = 'global';
30
31
    /**
32
     * @inheritdoc
33
     */
34
    public function init()
35
    {
36
        parent::init();
37
38
        // Components
39
        $this->setComponents([
40
            'transformers' => services\Transformers::class,
41
        ]);
42
43
        // Twig variables
44
        Event::on(
45
            CraftVariable::class,
46
            CraftVariable::EVENT_INIT,
47
            function (Event $event) {
48
                /** @var CraftVariable $variable */
49
                $variable = $event->sender;
50
                $variable->set('flux', static::getInstance());
51
            }
52
        );
53
    }
54
55
    /**
56
     * @inheritdoc
57
     */
58
    protected static function getLogFileName(): string
59
    {
60
        return 'flux';
61
    }
62
63
    /*******************************************
64
     * SERVICES
65
     *******************************************/
66
67
    /**
68
     * @noinspection PhpDocMissingThrowsInspection
69
     * @return services\Transformers
70
     */
71
    public function getTransformers(): services\Transformers
72
    {
73
        /** @noinspection PhpUnhandledExceptionInspection */
74
        /** @noinspection PhpIncompatibleReturnTypeInspection */
75
        return $this->get('transformers');
76
    }
77
}
78