LocalizerServiceProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 4
Bugs 1 Features 0
Metric Value
wmc 4
c 4
b 1
f 0
lcom 1
cbo 3
dl 0
loc 44
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 5 1
B boot() 0 25 3
1
<?php
2
3
namespace Aitor24\Localizer;
4
5
use Illuminate\Support\ServiceProvider;
6
use Unicodeveloper\Identify\IdentifyServiceProvider;
7
8
class LocalizerServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Bootstrap the application services.
12
     *
13
     * @return void
14
     */
15
    public function boot(\Illuminate\Routing\Router $router)
16
    {
17
        if (!$this->app->routesAreCached()) {
18
            require __DIR__.'/Routes/web.php';
19
        }
20
21
        $this->publishes([
22
            __DIR__.'/Config/localizer.php' => config_path('localizer.php'),
23
        ], 'localizer_config');
24
25
        $this->publishes([
26
            __DIR__.'/Config/localizer_languages.php' => config_path('localizer_languages.php'),
27
        ], 'localizer_languages');
28
29
        $router->aliasMiddleware('localizer', config('localizer.middleware'));
30
        $this->app->register(IdentifyServiceProvider::class);
31
32
        $this->publishes([
33
                __DIR__.'/Migrations/2016_11_28_115831_add_locale_column.php' => $this->app->databasePath().'/migrations/'.date('Y_m_d_His', time()).'_add_locale_column.php',
0 ignored issues
show
Bug introduced by
The method databasePath() does not exist on Illuminate\Contracts\Foundation\Application. Did you maybe mean basePath()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
34
        ], 'localizer_migrations');
35
36
        if (!config('localizer.dynamic_migration_name')) {
37
            $this->loadMigrationsFrom(__DIR__.'/Migrations', 'localizer');
0 ignored issues
show
Unused Code introduced by
The call to LocalizerServiceProvider::loadMigrationsFrom() has too many arguments starting with 'localizer'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
38
        }
39
    }
40
41
    /**
42
     * Register the application services.
43
     *
44
     * @return void
45
     */
46
    public function register()
47
    {
48
        $this->mergeConfigFrom(__DIR__.'/Config/localizer.php', 'localizer');
49
        $this->mergeConfigFrom(__DIR__.'/Config/localizer_languages.php', 'localizer_languages');
50
    }
51
}
52