Completed
Pull Request — master (#72)
by D.
21:32 queued 11:33
created

AppServiceProvider::buildLogComment()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 6
cts 6
cp 1
rs 9.2
c 0
b 0
f 0
cc 4
eloc 6
nc 3
nop 3
crap 4
1
<?php
2
3
namespace SET\Providers;
4
5
use Illuminate\Support\Facades\Cache;
6
use Illuminate\Support\ServiceProvider;
7
use SET\Handlers\DBConfigs\DBConfigs;
8
use SET\Setting;
9
10
class AppServiceProvider extends ServiceProvider
11
{
12
    /**
13
     * Bootstrap any application services.
14
     *
15
     * @return void
16
     */
17 162
    public function boot()
0 ignored issues
show
Coding Style introduced by
boot uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
18
    {
19 162
        // Ensure installation is not in progress
20
        if ( ! strpos($_SERVER['REQUEST_URI'],'install') ) {
21 162
          DBConfigs::execute();
22 10
        }
23 162
24 162
        Setting::saving(function ($setting) {
25
            Cache::forever($setting->key, $setting->value);
26
        });
27
    }
28
29
    /**
30
     * Register any application services.
31 162
     *
32
     * @return void
33 162
     */
34
    public function register()
35
    {
36 162
        if ($this->app->environment() == 'local') {
37
            $this->app->register('Laracasts\Generators\GeneratorsServiceProvider');
38
        }
39
    }
40
}
41