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

FriendsServiceProvider   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 77
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Test Coverage

Coverage 90.63%

Importance

Changes 5
Bugs 1 Features 0
Metric Value
wmc 9
c 5
b 1
f 0
lcom 2
cbo 1
dl 0
loc 77
rs 10
ccs 29
cts 32
cp 0.9063

5 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 5 1
A publishConfig() 0 9 2
A publishMigration() 0 15 3
A register() 0 7 2
A mergeConfig() 0 6 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