Completed
Push — master ( af3b76...53c498 )
by Manu
03:21
created

InventoryServiceProvider::publishConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
ccs 0
cts 9
cp 0
rs 9.6666
cc 1
eloc 5
nc 1
nop 0
crap 2
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 23 and the first side effect is on line 15.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
namespace Scool\Inventory\Providers;
3
use Acacha\Names\Providers\NamesServiceProvider;
4
use Acacha\Stateful\Providers\StatefulServiceProvider;
5
use Illuminate\Support\ServiceProvider;
6
use Scool\Inventory\ScoolInventory;
7
use Scool\Inventory\Stats\CacheableStatsRepository;
8
use Scool\Inventory\Stats\Contracts\StatsRepository as StatsRepositoryInterface;
9
use Scool\Inventory\Stats\StatsRepository;
10
/**
11
 * Class InventoryServiceProvider.
12
 *
13
 * @package Scool\Inventory\Providers
14
 */
15
class InventoryServiceProvider extends ServiceProvider
0 ignored issues
show
Bug introduced by
Possible parse error: class missing opening or closing brace
Loading history...
16
{
17
    /**
18
     * Register package services.
19
     */
20
    public function register()
21
    {
22
        if (!defined('SCOOL_INVENTORY_PATH')) {
23
            define('SCOOL_INVENTORY_PATH', realpath(__DIR__.'/../../'));
24
        }
25
<<<<<<< HEAD
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_SL
Loading history...
26
        $this->registerNamesServiceProvider();
27
        $this->registerStatefulEloquentServiceProvider();
28
        $this->bindRepositories();
29
        $this->app->bind(StatsRepositoryInterface::class,function() {
30
=======
31
        $this->app->register(NamesServiceProvider::class);
32
        $this->app->bind(\Scool\Inventory\Repositories\StudyRepository::class, \Scool\Inventory\Repositories\StudyRepositoryEloquent::class);
33
        $this->app->bind(StatsRepositoryInterface::class, function () {
34
>>>>>>> af3b7660d20378ee776d8126fd76cd529a6c647e
35
            return new CacheableStatsRepository(new StatsRepository());
36
        });
37
    }
38
39
    /**
40
     * Bind repositories
41
     */
42
    protected function bindRepositories()
43
    {
44
        $this->app->bind(
45
            \Scool\Inventory\Repositories\StudyRepository::class,
46
            \Scool\Inventory\Repositories\StudyRepositoryEloquent::class);
47
        $this->app->bind(\Scool\Inventory\Repositories\TodoRepository::class, \Scool\Inventory\Repositories\TodoRepositoryEloquent::class);
48
        $this->app->bind(\Scool\Inventory\Repositories\ShitRepository::class, \Scool\Inventory\Repositories\ShitRepositoryEloquent::class);
49
        //:end-bindings:
50
    }
51
    /**
52
     * Register acacha/stateful-eloquent Service Provider.
53
     *
54
     */
55
    protected function registerStatefulEloquentServiceProvider()
56
    {
57
        $this->app->register(StatefulServiceProvider::class);
58
    }
59
    /**
60
     * Register acacha/names Service Provider.
61
     *
62
     */
63
    protected function registerNamesServiceProvider()
64
    {
65
        $this->app->register(NamesServiceProvider::class);
66
    }
67
    /**
68
     * Bootstrap package services.
69
     *
70
     * @return void
71
     */
72
    public function boot()
73
    {
74
        $this->defineRoutes();
75
        $this->loadMigrations();
76
        $this->loadViews();
77
        $this->publishFactories();
78
        $this->publishConfig();
79
        $this->publishTests();
80
    }
81
82
    /**
83
     * Define the inventory routes.
84
     */
85
    protected function defineRoutes()
86
    {
87
        if (!$this->app->routesAreCached()) {
88
            $router = app('router');
89
            $router->group(['namespace' => 'Scool\Inventory\Http\Controllers'], function () {
90
                require __DIR__.'/../Http/routes.php';
91
            });
92
        }
93
    }
94
    /**
95
     * Load package views.
96
     */
97
    private function loadViews()
98
    {
99
        $this->loadViewsFrom(SCOOL_INVENTORY_PATH . '/resources/views', 'inventory');
100
    }
101
    /**
102
     * Load migrations.
103
     */
104
    private function loadMigrations()
105
    {
106
        $this->loadMigrationsFrom(SCOOL_INVENTORY_PATH . '/database/migrations');
107
    }
108
109
    /**
110
     * Publish factories.
111
     */
112
    private function publishFactories()
113
    {
114
        $this->publishes(
115
            ScoolInventory::factories(),"scool_inventory"
116
        );
117
    }
118
119
    /**
120
     * Publish config.
121
     */
122
    private function publishConfig() {
123
        $this->publishes(
124
            ScoolInventory::configs(),"scool_inventory"
125
        );
126
        $this->mergeConfigFrom(
127
            SCOOL_INVENTORY_PATH . '/config/inventory.php', 'scool_inventory'
128
        );
129
    }
130
<<<<<<< HEAD
131
    /**
132
     * Publich tests.
133
     */
134
=======
135
136
>>>>>>> af3b7660d20378ee776d8126fd76cd529a6c647e
137
    private function publishTests()
138
    {
139
        $this->publishes(
140
            [SCOOL_INVENTORY_PATH .'/tests/InventoryTest.php' => 'tests/InventoryTest.php'] ,
141
            'scool_inventory'
142
        );
143
    }
144
<<<<<<< HEAD
145
=======
146
147
    protected function defineRoutes()
148
    {
149
        if (!$this->app->routesAreCached()) {
150
            $router = app('router');
151
            $router->group(['namespace' => 'Scool\Inventory\Http\Controllers'], function () {
152
                require __DIR__.'/../Http/routes.php';
153
            });
154
        }
155
    }
156
157
    private function registerStatefulEloquentServiceProvider()
158
    {
159
        $this->app->register(StatefulServiceProvider::class);
160
    }
161
>>>>>>> af3b7660d20378ee776d8126fd76cd529a6c647e
162
}
163