Bootstrap::bootstrap()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 9.9332
c 0
b 0
f 0
cc 4
nc 4
nop 1
crap 4
1
<?php
2
/**
3
 * @link https://github.com/vuongxuongminh/yii2-searchable
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\searchable;
9
10
use yii\base\BootstrapInterface;
11
use yii\console\Application as ConsoleApp;
12
13
use vxm\searchable\console\CommandController;
14
15
/**
16
 * Class Bootstrap boot searchable component and console searchable controller.
17
 *
18
 * @author Vuong Minh <[email protected]>
19
 * @since 1.0.0
20
 */
21
class Bootstrap implements BootstrapInterface
22
{
23
24
    /**
25
     * @inheritDoc
26
     * @throws \yii\base\InvalidConfigException
27
     */
28 13
    public function bootstrap($app)
29
    {
30 13
        if (!$app->get('searchable', false)) {
31 13
            $app->set('searchable', ['class' => Searchable::class]);
32
        }
33
34 13
        if ($app instanceof ConsoleApp && !isset($app->controllerMap['searchable'])) {
35 13
            $app->controllerMap['searchable'] = CommandController::class;
36
        }
37 13
    }
38
39
}
40