AppServiceProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 15 2
A register() 0 4 2
1
<?php
2
3
namespace App\Providers;
4
5
use Acacha\User\GuestUser;
6
use App\Observers\TaskObserver;
7
use App\Task;
8
use Illuminate\Support\Facades\Auth;
9
use Illuminate\Support\ServiceProvider;
10
use Laravel\Dusk\DuskServiceProvider;
11
use View;
12
13
class AppServiceProvider extends ServiceProvider
14
{
15
    /**
16
     * Bootstrap any application services.
17
     *
18
     * @return void
19
     */
20
    public function boot()
21
    {
22
        View::composer('*', function($view){
23
24
            if(Auth::user()){
25
26
                $view->with('user',Auth::user());
27
28
            } else {
29
                //nullObject
30
                $view->with('user', new GuestUser);
31
            }
32
        });
33
34
        Task::observe(TaskObserver::class);
35
36
    }
37
38
    /**
39
     * Register any application services.
40
     *
41
     * @return void
42
     */
43
    public function register()
44
    {
45
        if ($this->app->environment('local', 'testing')) {
46
            $this->app->register(DuskServiceProvider::class);
47
        }
48
    }
49
}
50