HoneypotServiceProvider::boot()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 9.568
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
namespace Spatie\Honeypot;
4
5
use Illuminate\Support\Facades\Blade;
6
use Illuminate\Support\Facades\View;
7
use Illuminate\Support\ServiceProvider;
8
use Spatie\Honeypot\SpamResponder\SpamResponder;
9
10
class HoneypotServiceProvider extends ServiceProvider
11
{
12
    public function boot()
13
    {
14
        if ($this->app->runningInConsole()) {
15
            $this->publishes([
16
                __DIR__.'/../config/honeypot.php' => config_path('honeypot.php'),
17
            ], 'config');
18
19
            $this->publishes([
20
                __DIR__.'/../resources/views' => base_path('resources/views/vendor/honeypot'),
21
            ], 'views');
22
        }
23
24
        $this->loadViewsFrom(__DIR__.'/../resources/views', 'honeypot');
25
26
        View::composer('honeypot::honeypotFormFields', HoneypotViewComposer::class);
27
28
        Blade::directive('honeypot', function () {
29
            return "<?php echo view('honeypot::honeypotFormFields'); ?>";
30
        });
31
32
        $this->app->bind(SpamResponder::class, config('honeypot.respond_to_spam_with'));
33
    }
34
35
    public function register()
36
    {
37
        $this->mergeConfigFrom(__DIR__.'/../config/honeypot.php', 'honeypot');
38
    }
39
}
40