Passed
Pull Request — master (#13)
by Prasit
13:26
created

InvoiceServiceProvider::defineAssetPublishing()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 11
nc 1
nop 0
dl 0
loc 18
ccs 11
cts 11
cp 1
crap 1
rs 9.9
c 0
b 0
f 0
1
<?php
2
3
namespace Soap\Invoices\Providers;
4
5
use Illuminate\Support\ServiceProvider;
6
use Soap\Invoices\Services\InvoiceService;
7
use Soap\Invoices\Services\BillService;
8
use Soap\Invoices\Interfaces\BillServiceInterface;
9
use Soap\Invoices\Interfaces\InvoiceServiceInterface;
10
11
12
class InvoiceServiceProvider extends ServiceProvider
13
{
14
    /**
15
     * Perform post-registration booting of services.
16
     *
17
     * @return void
18
     */
19 57
    public function boot()
20
    {
21 57
        $this->registerResources();
22
23 57
        $this->defineAssetPublishing();
24
25 57
    }
26
27
    /**
28
     * Register any package services.
29
     *
30
     * @return void
31
     */
32 57
    public function register()
33
    {
34 57
        $this->configure();
35
        
36 57
        $this->registerServices();
37
        
38 57
    }
39
40
    /**
41
     * Setup the configuration for Invoices.
42
     *
43
     * @return void
44
     */
45 57
    protected function configure()
46
    {
47 57
        $this->mergeConfigFrom(__DIR__ . '/../../config/soap.invoices.php', 'soap.invoices');
48 57
    }
49
50 57
    protected function registerResources()
51
    {
52 57
        $sourceViewsPath = __DIR__ . '/../../resources/views';
53 57
        $this->loadViewsFrom($sourceViewsPath, 'invoices');
54 57
    }
55
56
    /**
57
     * Define the asset publishing configuration.
58
     *
59
     * @return void
60
     */
61 57
    protected function defineAssetPublishing()
62
    {
63 57
        $sourceViewsPath = __DIR__ . '/../../resources/views';
64
65 57
        $this->publishes([
66 57
            $sourceViewsPath => resource_path('views/vendor/invoices'),
67 57
        ], 'views');
68
69
        // Publish a config file
70 57
        $this->publishes([
71 57
            __DIR__ . '/../../config/soap.invoices.php' => config_path('soap.invoices.php'),
72 57
        ], 'config');
73
74
        // Publish migrations
75 57
        $this->publishes([
76
            __DIR__ . '/../../database/migrations/2020_02_10_163005_create_invoices_tables.php'
77 57
            => database_path('migrations/2020_02_10_163005_create_invoices_tables.php'),
78 57
        ], 'migrations');
79 57
    }
80
81
    /**
82
     * Setup the resource publishing groups for Invoices.
83
     *
84
     * @return void
85
     */
86
    protected function offerPublishing()
87
    {
88
        if ($this->app->runningInConsole()) {
89
            // Publishing the configuration file.
90
            $this->publishes([
91
                __DIR__ . '/../config/soap.invoices.php' => config_path('soap.invoices.php'),
92
            ], 'invoices.config');
93
94
            // Publishing the views.
95
            $this->publishes([
96
                __DIR__ . '/../resources/views' => base_path('resources/views/vendor/invoices'),
97
            ], 'invoices.views');
98
99
            // Publishing the translation files.
100
            $this->publishes([
101
                __DIR__ . '/../resources/lang' => resource_path('lang/vendor/invoices'),
102
            ], 'invoices.translations');
103
        }
104
    }
105
106 57
    protected function registerServices()
107
    {
108 57
        $this->app->bind(InvoiceServiceInterface::class, function ($app) {
0 ignored issues
show
Unused Code introduced by
The parameter $app is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

108
        $this->app->bind(InvoiceServiceInterface::class, function (/** @scrutinizer ignore-unused */ $app) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
109 24
            return new InvoiceService();
110 57
        });
111
        
112 57
        $this->app->bind(BillServiceInterface::class, function ($app) {
0 ignored issues
show
Unused Code introduced by
The parameter $app is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

112
        $this->app->bind(BillServiceInterface::class, function (/** @scrutinizer ignore-unused */ $app) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
113 24
            return new BillService();
114 57
        });
115 57
    }
116
117
    /**
118
     * Get the services provided by the provider.
119
     *
120
     * @return array
121
     */
122
    public function provides()
123
    {
124
        return ['invoice'];
125
    }
126
}
127