LaravelApiResponsesServiceProvider::boot()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 9.6333
c 0
b 0
f 0
cc 3
nc 3
nop 0
1
<?php
2
3
namespace Igorsgm\LaravelApiResponses;
4
5
use Illuminate\Support\ServiceProvider;
6
7
class LaravelApiResponsesServiceProvider extends ServiceProvider
8
{
9
    /**
10
     * Bootstrap the application services.
11
     */
12
    public function boot()
13
    {
14
        if ($this->app->runningInConsole()) {
15
            $this->publishes([
16
                __DIR__.'/../config/laravel-api-responses.php' => config_path('laravel-api-responses.php'),
17
            ], 'config');
18
19
            if (!file_exists(base_path('_ide_helper_macros.php'))) {
20
                // Publishing ide helper file.
21
                $this->publishes([
22
                    __DIR__.'/../_ide_helper_macros.php.stub' => base_path('_ide_helper_macros.php'),
23
                ]);
24
25
                // Adding _ide_helper_macros.php file to .gitignore
26
                $gitignoreFile = base_path('.gitignore');
27
                file_put_contents($gitignoreFile, file_get_contents($gitignoreFile) . "\n_ide_helper_macros.php");
28
            }
29
        }
30
    }
31
32
    /**
33
     * Register the application services.
34
     */
35
    public function register()
36
    {
37
        // Automatically apply the package configuration
38
        $this->mergeConfigFrom(__DIR__.'/../config/laravel-api-responses.php', 'laravel-api-responses');
39
40
        // Register the response Macros
41
        $this->app->make(LaravelApiResponses::class);
42
    }
43
}
44