Completed
Push — master ( bdfc8a...37ff51 )
by Abdelrahman
03:04 queued 01:51
created

StatisticsServiceProvider::publishResources()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Rinvex\Statistics\Providers;
6
7
use Illuminate\Routing\Router;
8
use Rinvex\Statistics\Models\Path;
9
use Rinvex\Statistics\Models\Agent;
10
use Rinvex\Statistics\Models\Datum;
11
use Rinvex\Statistics\Models\Geoip;
12
use Rinvex\Statistics\Models\Route;
13
use Rinvex\Statistics\Models\Device;
14
use Rinvex\Statistics\Models\Request;
15
use Rinvex\Statistics\Models\Platform;
16
use Illuminate\Support\ServiceProvider;
17
use Rinvex\Support\Traits\ConsoleTools;
18
use Rinvex\Statistics\Console\Commands\MigrateCommand;
19
use Rinvex\Statistics\Console\Commands\PublishCommand;
20
use Rinvex\Statistics\Http\Middleware\TrackStatistics;
21
use Rinvex\Statistics\Console\Commands\RollbackCommand;
22
23
class StatisticsServiceProvider extends ServiceProvider
24
{
25
    use ConsoleTools;
26
27
    /**
28
     * The commands to be registered.
29
     *
30
     * @var array
31
     */
32
    protected $commands = [
33
        MigrateCommand::class => 'command.rinvex.statistics.migrate',
34
        PublishCommand::class => 'command.rinvex.statistics.publish',
35
        RollbackCommand::class => 'command.rinvex.statistics.rollback',
36
    ];
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function register()
42
    {
43
        // Merge config
44
        $this->mergeConfigFrom(realpath(__DIR__.'/../../config/config.php'), 'rinvex.statistics');
45
46
        // Bind eloquent models to IoC container
47
        $this->app->singleton('rinvex.statistics.datum', $datumModel = $this->app['config']['rinvex.statistics.models.datum']);
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 127 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
48
        $datumModel === Datum::class || $this->app->alias('rinvex.statistics.datum', Datum::class);
49
50
        $this->app->singleton('rinvex.statistics.request', $requestModel = $this->app['config']['rinvex.statistics.models.request']);
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 133 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
51
        $requestModel === Request::class || $this->app->alias('rinvex.statistics.request', Request::class);
52
53
        $this->app->singleton('rinvex.statistics.agent', $agentModel = $this->app['config']['rinvex.statistics.models.agent']);
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 127 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
54
        $agentModel === Agent::class || $this->app->alias('rinvex.statistics.agent', Agent::class);
55
56
        $this->app->singleton('rinvex.statistics.geoip', $geoipModel = $this->app['config']['rinvex.statistics.models.geoip']);
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 127 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
57
        $geoipModel === Geoip::class || $this->app->alias('rinvex.statistics.geoip', Geoip::class);
58
59
        $this->app->singleton('rinvex.statistics.route', $routeModel = $this->app['config']['rinvex.statistics.models.route']);
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 127 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
60
        $routeModel === Route::class || $this->app->alias('rinvex.statistics.route', Route::class);
61
62
        $this->app->singleton('rinvex.statistics.device', $deviceModel = $this->app['config']['rinvex.statistics.models.device']);
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 130 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
63
        $deviceModel === Device::class || $this->app->alias('rinvex.statistics.device', Device::class);
64
65
        $this->app->singleton('rinvex.statistics.platform', $platformModel = $this->app['config']['rinvex.statistics.models.platform']);
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 136 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
66
        $platformModel === Platform::class || $this->app->alias('rinvex.statistics.platform', Platform::class);
67
68
        $this->app->singleton('rinvex.statistics.path', $pathModel = $this->app['config']['rinvex.statistics.models.path']);
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 124 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
69
        $pathModel === Path::class || $this->app->alias('rinvex.statistics.path', Path::class);
70
71
        // Register console commands
72
        ! $this->app->runningInConsole() || $this->registerCommands();
73
    }
74
75
    /**
76
     * {@inheritdoc}
77
     */
78
    public function boot(Router $router)
79
    {
80
        // Publish Resources
81
        ! $this->app->runningInConsole() || $this->publishesConfig('rinvex/laravel-statistics');
82
        ! $this->app->runningInConsole() || $this->publishesMigrations('rinvex/laravel-statistics');
83
84
        // Push middleware to web group
85
        $router->pushMiddlewareToGroup('web', TrackStatistics::class);
86
    }
87
}
88