PasswordServiceProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 13
c 1
b 0
f 0
dl 0
loc 37
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 18 3
A register() 0 5 1
1
<?php
2
3
namespace Benjafield\LaravelPasswordManager;
4
5
use Benjafield\LaravelPasswordManager\Commands\GeneratePasswordKeyCommand;
6
use Illuminate\Support\ServiceProvider;
7
8
class PasswordServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Register package services.
12
     *
13
     * @return void
14
     */
15
    public function register()
16
    {
17
        $this->mergeConfigFrom(__DIR__ . '/../config/passwords.php', 'passwords');
18
19
        $this->app->bind('passwords', fn () => new PasswordManager);
20
    }
21
22
    /**
23
     * Bootstrap package services.
24
     *
25
     * @return void
26
     */
27
    public function boot()
28
    {
29
        if ($this->app->runningInConsole()) {
30
            // Publish the config file.
31
            $this->publishes([
32
                __DIR__ . '/../config/passwords.php' => config_path('passwords.php'),
33
            ], 'config');
34
35
            // Publish the database migrations
36
            if (! class_exists('CreatePasswordsTable')) {
37
                $this->publishes([
38
                    __DIR__ . '/../database/migrations/create_passwords_table.php.stub' => database_path('migrations/' . date('Y_m_d_His', time()) . '_create_passwords_table.php'),
39
                ], 'migrations');
40
            }
41
42
            // Register console commands.
43
            $this->commands([
44
                GeneratePasswordKeyCommand::class,
45
            ]);
46
        }
47
    }
48
}