Completed
Push — master ( 80af1b...f425bf )
by Manu
02:30
created

InventoryServiceProvider::publishTests()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 7
ccs 0
cts 7
cp 0
rs 9.4285
cc 1
eloc 4
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 18 and the first side effect is on line 13.

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
3
namespace Scool\Inventory\Providers;
4
5
use Acacha\Names\Providers\NamesServiceProvider;
6
use Illuminate\Support\ServiceProvider;
7
use Acacha\Stateful\Providers\StatatefulServiceProvider;
8
use Scool\Inventory\ScoolInventory;
9
10
/**
11
 * Class InventoryServiceProvider.
12
 */
13
class InventoryServiceProvider extends ServiceProvider
0 ignored issues
show
Bug introduced by
Possible parse error: class missing opening or closing brace
Loading history...
14
{
15
    /**
16
     * Register package services.
17
     */
18
    public function register()
19
    {
20
        if (!defined('SCOOL_INVENTORY_PATH')) {
21
            define('SCOOL_INVENTORY_PATH', realpath(__DIR__.'/../../'));
22
        }
23
        $this->app->register(NamesServiceProvider::class);
24
        $this->app->bind(\Scool\Inventory\Repositories\StudyRepository::class, \Scool\Inventory\Repositories\StudyRepositoryEloquent::class);
25
        $this->app->bind(StatsRepositoryInterface::class,function() {
26
            return new CacheableStatsRepository(new StatsRepository());
27
        });
28
    }
29
    /**
30
     * Bootstrap package services.
31
     *
32
     * @return void
33
     */
34
    public function boot()
35
    {
36
        $this->defineRoutes();
37
        $this->loadMigrations();
38
        $this->publishFactories();
39
        $this->publishConfig();
40
        $this->publishTests();
41
    }
42
    /**
43
     * Load migrations.
44
     */
45
    private function loadMigrations()
46
    {
47
        $this->loadMigrationsFrom(SCOOL_INVENTORY_PATH.'/database/migrations');
48
    }
49
    /**
50
     * Publish factories.
51
     */
52
    private function publishFactories()
53
    {
54
        $this->publishes(
55
            ScoolInventory::factories(), 'scool_inventory'
56
        );
57
    }
58
    /**
59
     * Publish config.
60
     */
61
    private function publishConfig()
62
    {
63
        $this->publishes(
64
            ScoolInventory::configs(), 'scool_inventory'
65
        );
66
        $this->mergeConfigFrom(
67
            SCOOL_INVENTORY_PATH.'/config/inventory.php', 'scool_inventory'
68
        );
69
    }
70
    private function publishTests()
71
    {
72
        $this->publishes(
73
            [SCOOL_INVENTORY_PATH.'/tests/InventoryTest.php' => 'tests/InventoryTest.php'],
74
<<<<<<< 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...
75
            'scool_inventory'
76
=======
77
            'scool_curriculum'
78
>>>>>>> 80af1b0c8bb867379f66912ed39f99dd26f04530
79
        );
80
    }
81
82
    protected function defineRoutes()
83
    {
84
        if (!$this->app->routesAreCached()) {
85
            $router = app('router');
86
            $router->group(['namespace' => 'Scool\Inventory\Http\Controllers'], function () {
87
            require __DIR__.'/../Http/routes.php';
88
            });
89
        }
90
    }
91
92
    private function registerStatefulEloquentServiceProvider ()
93
    {
94
        $this->app->register(StatefulServiceProvider::class);
95
    }
96
}
97