Passed
Push — master ( 48d02b...1e0cee )
by Austin
03:14
created

SecurityTxtServiceProvider::getInstance()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
/**
3
 * src/SecurityTxtServiceProvider.php.
4
 *
5
 * @author      Austin Heap <[email protected]>
6
 * @version     v0.3.2
7
 */
8
declare(strict_types=1);
9
10
namespace AustinHeap\Security\Txt;
11
12
/**
13
 * SecurityTxtServiceProvider.
14
 *
15
 * @link        https://github.com/austinheap/laravel-security-txt
16
 * @link        https://packagist.org/packages/austinheap/laravel-security-txt
17
 * @link        https://austinheap.github.io/laravel-security-txt/classes/AustinHeap.Security.Txt.SecurityTxtServiceProvider.html
18
 */
19
class SecurityTxtServiceProvider extends \Illuminate\Support\ServiceProvider
20
{
21
    /**
22
     * Indicates if loading of the provider is deferred.
23
     *
24
     * @var bool
25
     */
26
    protected $defer = false;
27
28
    /**
29
     * Perform post-registration booting of services.
30
     *
31
     * @return void
32
     */
33
    public function boot()
34
    {
35
        $this->publishes([
36
            __DIR__ . '/config/security-txt.php' => config_path('security-txt.php'),
37
        ]);
38
39
        if (! $this->app->routesAreCached()) {
40
            require __DIR__ . '/routes/security-txt.php';
41
        }
42
43
        if (! defined('LARAVEL_SECURITY_TXT_VERSION')) {
44
            define('LARAVEL_SECURITY_TXT_VERSION', SecurityTxtHelper::VERSION);
45
        }
46
    }
47
48
    /**
49
     * Register the service provider.
50
     *
51
     * @return void
52
     */
53
    public function register()
54
    {
55
        $this->mergeConfigFrom(
56
            __DIR__.'/config/security-txt.php', 'security-txt'
57
        );
58
59
        $this->app->singleton('SecurityTxt', function () {
60
            return new SecurityTxtHelper;
61
        });
62
    }
63
64
    /**
65
     * @return \AustinHeap\Security\Txt\SecurityTxtHelper
66
     */
67
    public static function getInstance()
68
    {
69
        return app('SecurityTxt');
70
    }
71
}
72