BackupShieldServiceProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
dl 0
loc 49
rs 10
c 1
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 4 1
A boot() 0 14 1
A __construct() 0 4 1
1
<?php
2
3
namespace Olssonm\BackupShield;
4
5
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
6
use Illuminate\Support\Facades\Event;
7
8
use Spatie\Backup\Events\BackupZipWasCreated;
9
use Olssonm\BackupShield\Listeners\PasswordProtectZip;
10
11
/**
12
 * Laravel service provider for the Backup Shield-package
13
 */
14
class BackupShieldServiceProvider extends ServiceProvider
15
{
16
    /**
17
     * Config-path
18
     * @var string
19
     */
20
    protected $config;
21
22
    /**
23
     * Constructor
24
     *
25
     * @param \Illuminate\Foundation\Application $app
26
     */
27
    public function __construct($app) {
28
        $this->config = __DIR__ . '/config/backup-shield.php';
29
30
        parent::__construct($app);
31
    }
32
33
    /**
34
     * Perform post-registration booting of services.
35
     *
36
     * @return void
37
     */
38
    public function boot() : void
39
    {
40
        // Publishing of configuration
41
        $this->publishes([
42
            $this->config => config_path('backup-shield.php'),
43
        ]);
44
45
        // Listen for the "BackupZipWasCreated" event
46
        Event::listen(
47
            BackupZipWasCreated::class,
48
            PasswordProtectZip::class
49
        );
50
51
        parent::boot();
52
    }
53
54
    /**
55
     * Register any package services.
56
     *
57
     * @return void
58
     */
59
    public function register() : void
60
    {
61
        $this->mergeConfigFrom(
62
            $this->config, 'backup-shield'
63
        );
64
    }
65
}
66