Bootstrap   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 16
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A bootstrap() 0 8 1
1
<?php
2
/**
3
 * @link https://github.com/vuongxuongminh/yii2-desktop-notifier
4
 * @copyright Copyright (c) 2019 Vuong Xuong Minh
5
 * @license [New BSD License](http://www.opensource.org/licenses/bsd-license.php)
6
 */
7
8
namespace vxm\desktopNotifier;
9
10
use yii\base\Event;
11
use yii\base\BootstrapInterface;
12
use yii\console\Controller;
13
14
/**
15
 * Class Bootstrap help to attach an `\vxm\desktopNotifier\Behavior` to all `\yii\console\Controller` provide methods of it to controllers.
16
 *
17
 * @author Vuong Minh <[email protected]>
18
 * @since 1.0.0
19
 */
20
class Bootstrap implements BootstrapInterface
21
{
22
23
    /**
24
     * @inheritDoc
25
     */
26
    public function bootstrap($app)
27
    {
28 2
        Event::on(Controller::class, Controller::EVENT_BEFORE_ACTION, function (Event $event) {
29
            /** @var Controller $controller */
30 2
            $controller = $event->sender;
31 2
            $controller->attachBehavior('__desktopNotifier', Behavior::class);
32 2
        });
33
    }
34
35
}
36