AuthorizeNetServiceProvider   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 16
c 1
b 0
f 1
dl 0
loc 57
rs 10
wmc 9

4 Methods

Rating   Name   Duplication   Size   Complexity  
A publishConfig() 0 9 3
A loadMigrations() 0 7 3
A register() 0 6 2
A boot() 0 4 1
1
<?php
2
3
namespace Squareetlabs\AuthorizeNet\Providers;
4
5
use Illuminate\Support\ServiceProvider;
6
7
class AuthorizeNetServiceProvider extends ServiceProvider
8
{
9
    /**
10
     * Register any application services.
11
     *
12
     * @return void
13
     */
14
    public function register(): void
15
    {
16
        $configPath = __DIR__.'/../../config/authorizenet.php';
17
        
18
        if (file_exists($configPath)) {
19
            $this->mergeConfigFrom($configPath, 'authorizenet');
20
        }
21
    }
22
23
    /**
24
     * Bootstrap any application services.
25
     *
26
     * @return void
27
     */
28
    public function boot(): void
29
    {
30
        $this->loadMigrations();
31
        $this->publishConfig();
32
    }
33
34
    /**
35
     * Load package migrations.
36
     *
37
     * @return void
38
     */
39
    protected function loadMigrations(): void
40
    {
41
        if ($this->app->runningInConsole()) {
42
            $migrationsPath = __DIR__.'/../../database/migrations';
43
            
44
            if (is_dir($migrationsPath)) {
45
                $this->loadMigrationsFrom($migrationsPath);
46
            }
47
        }
48
    }
49
50
    /**
51
     * Publish the configuration file.
52
     *
53
     * @return void
54
     */
55
    protected function publishConfig(): void
56
    {
57
        if ($this->app->runningInConsole()) {
58
            $configPath = __DIR__.'/../../config/authorizenet.php';
59
            
60
            if (file_exists($configPath)) {
61
                $this->publishes([
62
                    $configPath => config_path('authorizenet.php'),
63
                ], 'authorizenet-config');
64
            }
65
        }
66
    }
67
68
69
70
}
71