Bootstrap   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 88.24%

Importance

Changes 0
Metric Value
dl 0
loc 32
ccs 15
cts 17
cp 0.8824
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A bootstrap() 0 24 4
1
<?php
2
3
namespace bedezign\yii2\audit;
4
use yii\base\Application;
5
use yii\base\BootstrapInterface;
6
7
/**
8
 * Bootstrap
9
 * @package bedezign\yii2\audit
10
 */
11
class Bootstrap implements BootstrapInterface
12
{
13
    /**
14
     * Bootstrap method to be called during application bootstrap stage.
15
     *
16
     * @param Application $app the application currently running
17
     */
18 75
    public function bootstrap($app)
19
    {
20
        // Make sure to register the base folder as alias as well or things like assets won't work anymore
21 75
        \Yii::setAlias('@bedezign/yii2/audit', __DIR__);
22
23 75
        if ($app instanceof \yii\console\Application) {
24
            $app->controllerMap['audit'] = 'bedezign\yii2\audit\commands\AuditController';
25
        }
26
27 75
        $moduleName = Audit::findModuleIdentifier();
28 75
        if ($moduleName) {
29
            // The module was added in the configuration, make sure to add it to the application bootstrap so it gets loaded
30 75
            $app->bootstrap[] = $moduleName;
31 75
            $app->bootstrap = array_unique($app->bootstrap, SORT_REGULAR);
32 75
        }
33
34 75
        if ($app->has('i18n')) {
35 75
            $app->i18n->translations['audit'] = [
36 75
                'class'          => 'yii\i18n\PhpMessageSource',
37 75
                'sourceLanguage' => 'en',
38 75
                'basePath'       => '@bedezign/yii2/audit/messages',
39
            ];
40 75
        }
41 75
    }
42
}
43