Completed
Push — master ( 3cffd3...830b6c )
by Christopher
06:58
created

FriendsServiceProvider::mergeConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
ccs 5
cts 5
cp 1
cc 1
eloc 3
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * This file is part of Friends.
4
 *
5
 * (c) Christopher Lass <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Arubacao\Friends;
12
13
use Illuminate\Support\ServiceProvider;
14
15
class FriendsServiceProvider extends ServiceProvider
16
{
17
    /**
18
     * Indicates if loading of the provider is deferred.
19
     *
20
     * @var bool
21
     */
22
    protected $defer = false;
23
24
    /**
25
     * Bootstrap the application events.
26
     *
27
     * @return void
28
     */
29 26
    public function boot()
30
    {
31 26
        $this->publishConfig();
32 26
        $this->publishMigration();
33 26
    }
34
35
    /**
36
     * Publish Friends configuration.
37
     */
38 26
    protected function publishConfig()
39
    {
40 26
        if (function_exists('config_path')) {
41
            // Publish config files
42 26
            $this->publishes([
43 26
                __DIR__.'/../config/friends.php' => config_path('friends.php'),
44 26
            ]);
45 26
        }
46 26
    }
47
48
    /**
49
     * Publish Friends migration.
50
     */
51 26
    protected function publishMigration()
52
    {
53 26
        if (class_exists('CreateFriendsTable')) {
54 25
            return;
55
        }
56
57 1
        $published_migration = glob(database_path('/migrations/*_create_friends_table.php'));
58 1
        if (count($published_migration) != 0) {
59
            return;
60
        }
61
62 1
        $stub = __DIR__.'/../database/migrations/2016_06_18_000000_create_friends_table.php';
63 1
        $target = database_path('/migrations/'.date('Y_m_d_His').'_create_friends_table.php');
64 1
        $this->publishes([$stub => $target], 'migrations');
65 26
    }
66
67
    /**
68
     * Register the service provider.
69
     *
70
     * @return void
71
     */
72 26
    public function register()
73
    {
74 26
        if(method_exists($this->app,'configure')) {
75
            $this->app->configure('friends');
0 ignored issues
show
Bug introduced by
The method configure() does not exist on Illuminate\Contracts\Foundation\Application. Did you maybe mean registerConfiguredProviders()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
76
        }
77 26
        $this->mergeConfig();
78 26
    }
79
80
    /**
81
     * Merges user's and friends's configs.
82
     *
83
     * @return void
84
     */
85 26
    protected function mergeConfig()
86
    {
87 26
        $this->mergeConfigFrom(
88 26
            __DIR__.'/../config/friends.php', 'friends'
89 26
        );
90 26
    }
91
}
92