Bootstrap   A
last analyzed

Complexity

Total Complexity 17

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 17
lcom 0
cbo 5
dl 0
loc 67
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
F bootstrap() 0 63 17
1
<?php
2
3
/*
4
 * This file is part of the Cjt Terabyte LLC [yii2-extension].
5
 *
6
 * (c) Cjt Terabyte LLC [yii2-extension] <http://github.com/cjtterabytesoft>.
7
 * For the full copyright and license information, please view the LICENSE.md.
8
 * file that was distributed with this source code.
9
 *
10
 * @link http://www.cjtterabyte.com.
11
 * @author Wilmer Arámbula <[email protected]>.
12
 * @copyright (c) 2015 Cjt Terabyte LLC.
13
 * @Extension: [yii2-adminlte-basic].
14
 * @Configuration App [Bootstrap].
15
 * @since 1.0
16
 */
17
18
namespace cjtterabytesoft\adminlte\basic;
19
20
use Yii;
21
use yii\base\BootstrapInterface;
22
use yii\i18n\PhpMessageSource;
23
24
class Bootstrap implements BootstrapInterface
25
{
26
    /** @inheritdoc */
27
    public function bootstrap($app)
0 ignored issues
show
Coding Style Best Practice introduced by
Please use __construct() instead of a PHP4-style constructor that is named after the class.
Loading history...
28
    {
29
        /* Config Translation */
30
        if (!isset($app->get('i18n')->translations['adminlte*'])) {
31
            $app->get('i18n')->translations['adminlte*'] = [
32
                'class'    => PhpMessageSource::className(),
33
                'basePath' => __DIR__ . '/messages',
34
            ];
35
        }
36
        /* Config Theme */
37
        if (!isset($app->view->theme)) {
38
            $app->view->theme = new \yii\base\Theme([
39
                'pathMap' => [
40
                    '@app/views/layouts' => '@cjtterabytesoft/adminlte/basic/views/layouts',
41
                    '@app/views/site' => '@cjtterabytesoft/adminlte/basic/views/site',
42
                ],
43
            ]);
44
        }
45
        /* Copy Avatar Images */
46
        if (\yii\helpers\BaseFileHelper::filterPath(\Yii::getAlias('@app/web/images'), $options = [])) {
0 ignored issues
show
Bug introduced by
It seems like \Yii::getAlias('@app/web/images') targeting yii\BaseYii::getAlias() can also be of type boolean; however, yii\helpers\BaseFileHelper::filterPath() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
47
            \yii\helpers\BaseFileHelper::copyDirectory(\Yii::getAlias('@cjtterabytesoft/adminlte/basic/images/'), \Yii::getAlias('@app/web/images'));
0 ignored issues
show
Bug introduced by
It seems like \Yii::getAlias('@cjttera...dminlte/basic/images/') targeting yii\BaseYii::getAlias() can also be of type boolean; however, yii\helpers\BaseFileHelper::copyDirectory() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
Bug introduced by
It seems like \Yii::getAlias('@app/web/images') targeting yii\BaseYii::getAlias() can also be of type boolean; however, yii\helpers\BaseFileHelper::copyDirectory() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
48
        }
49
        /* Config Params */
50
        if (!isset($app->params['adminEmail'])) {
51
            $app->params['adminEmail'] = '[email protected]';
52
        }
53
        if (!isset($app->params['AdminLTESkin'])) {
54
            $app->params['AdminLTESkin'] = 'skin-yellow';
55
        }
56
        if (!isset($app->params['Author'])) {
57
            $app->params['Author'] = '2015 - Wilmer Arambula';
58
        }
59
        if (!isset($app->params['Facebook_Account'])) {
60
            $app->params['Facebook_Account'] = 'https://www.facebook.com/username';
61
        }
62
        if (!isset($app->params['Google_Account'])) {
63
            $app->params['Google_Account'] = 'https://www.google.com/+username';
64
        }
65
        if (!isset($app->params['Linkedin_Account'])) {
66
            $app->params['Linkedin_Account'] = 'https://www.linkedin.com/in/username';
67
        }
68
        if (!isset($app->params['Twitter_Account'])) {
69
            $app->params['Twitter_Account'] = 'https://twitter.com/username';
70
        }
71
        if (!isset($app->params['WebName'])) {
72
            $app->params['WebName'] = 'My Application';
73
        }
74
        if (!YII_ENV_TEST) {
75
            if (!isset($app->params['imagesurl_30'])) {
76
                $app->params['imagesurl_30'] = 'http://www.basic.tk/images/avatar/profile/30/icon-avatar.png';
77
            }
78
            if (!isset($app->params['imagesurl_60'])) {
79
                $app->params['imagesurl_60'] = 'http://www.basic.tk/images/avatar/profile/60/icon-avatar.png';
80
            }
81
            } else {
82
                if (!isset($app->params['imagesurl_30'])) {
83
                    $app->params['imagesurl_30'] = 'http://localhost.basic/images/avatar/profile/30/icon-avatar.png';
84
                }
85
                if (!isset($app->params['imagesurl_60'])) {
86
                    $app->params['imagesurl_60'] = 'http://localhost.basic/images/avatar/profile/60/icon-avatar.png';
87
                }
88
        }
89
    }
90
}