LarapayServiceProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 49
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getConfigPath() 0 3 1
A register() 0 6 1
A getDatabasePath() 0 3 1
A boot() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Nxmad\Larapay;
6
7
use Nxmad\Larapay\Contracts\Payments;
8
use Illuminate\Support\ServiceProvider;
9
10
class LarapayServiceProvider extends ServiceProvider
11
{
12
    /**
13
     * Register Service Provider.
14
     *
15
     * @return void
16
     */
17
    public function register()
18
    {
19
        $this->mergeConfigFrom($this->getConfigPath(), 'larapay');
20
21
        $this->app->singleton(Payments::class, function ($app) {
22
            return new GatewayManager($app['config']);
23
        });
24
    }
25
26
    /**
27
     * Boot Service Provider.
28
     *
29
     * @return void
30
     */
31
    public function boot()
32
    {
33
        $this->publishes([
34
            $this->getDatabasePath() => database_path(),
0 ignored issues
show
Bug introduced by
The function database_path was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

34
            $this->getDatabasePath() => /** @scrutinizer ignore-call */ database_path(),
Loading history...
35
            $this->getConfigPath() => config_path('larapay.php'),
0 ignored issues
show
Bug introduced by
The function config_path was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

35
            $this->getConfigPath() => /** @scrutinizer ignore-call */ config_path('larapay.php'),
Loading history...
36
        ]);
37
38
        $this->loadViewsFrom(__DIR__ . '/../files/views', 'larapay');
39
    }
40
41
    /**
42
     * Get default config path.
43
     *
44
     * @return string
45
     */
46
    protected function getConfigPath(): string
47
    {
48
        return __DIR__ . '/../files/config/larapay.php';
49
    }
50
51
    /**
52
     * Get default database path.
53
     *
54
     * @return string
55
     */
56
    protected function getDatabasePath(): string
57
    {
58
        return __DIR__ . '/../files/database';
59
    }
60
}
61