SimpleRecaptchaV3ServiceProvider::boot()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 24
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 5
Bugs 0 Features 0
Metric Value
cc 2
eloc 15
c 5
b 0
f 0
nc 2
nop 0
dl 0
loc 24
rs 9.7666
1
<?php
2
3
namespace Torralbodavid\SimpleRecaptchaV3;
4
5
use Illuminate\Support\Facades\Blade;
6
use Illuminate\Support\ServiceProvider;
7
8
class SimpleRecaptchaV3ServiceProvider extends ServiceProvider
9
{
10
    public function boot()
11
    {
12
        $this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'simple-recaptcha-v3');
13
        $this->loadViewsFrom(__DIR__.'/../resources/views', 'simple-recaptcha-v3');
14
15
        if ($this->app->runningInConsole()) {
16
            $this->publishes([
17
                __DIR__.'/../config/config.php' => config_path('simple-recaptcha-v3.php'),
18
            ], 'config');
19
20
            $this->publishes([
21
                __DIR__.'/../resources/views' => resource_path('views/vendor/simple-recaptcha-v3'),
22
            ], 'views');
23
24
            $this->publishes([
25
                __DIR__.'/../resources/lang' => resource_path('lang/vendor/simple-recaptcha-v3'),
26
            ], 'lang');
27
        }
28
29
        Blade::directive('captcha', function ($action) {
30
            return "<?php echo view('simple-recaptcha-v3::captcha', ['action' => {$action}]); ?>";
31
        });
32
33
        Blade::include('simple-recaptcha-v3::captcha-init', 'captcha_init');
34
    }
35
36
    public function register()
37
    {
38
        $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'simple-recaptcha-v3');
39
40
        $this->app->singleton('simple-recaptcha-v3', function () {
41
            return new SimpleRecaptchaV3;
42
        });
43
    }
44
}
45