Completed
Push — dev ( 4f11ce...5d65d1 )
by Alies
06:00 queued 01:47
created

ViewServiceProvider::boot()   D

Complexity

Conditions 18
Paths 1

Size

Total Lines 51
Code Lines 40

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 40
nc 1
nop 0
dl 0
loc 51
c 0
b 0
f 0
cc 18
rs 4.8666

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace Diglabby\Doika\Providers;
4
5
use Collective\Html\FormFacade;
6
use Collective\Html\HtmlFacade;
7
use Illuminate\Support\Facades\View;
8
use Illuminate\Support\ServiceProvider;
9
10
class ViewServiceProvider extends ServiceProvider
11
{
12
    /**
13
     * Bootstrap the application services.
14
     */
15
    public function boot()
16
    {
17
        FormFacade::component('bsText', 'components.form.input', ['name', 'value' => null, 'attributes' => [], 'type' => 'text']);
18
        FormFacade::component('bsEmail', 'components.form.input', ['name', 'value' => null, 'attributes' => [], 'type' => 'email']);
19
        FormFacade::component('bsTel', 'components.form.input', ['name', 'value' => null, 'attributes' => [], 'type' => 'tel']);
20
        FormFacade::component('bsNumber', 'components.form.input', ['name', 'value' => null, 'attributes' => [], 'type' => 'number']);
21
        FormFacade::component('bsDatetime', 'components.form.input', ['name', 'value' => null, 'attributes' => [], 'type' => 'datetime']);
22
        FormFacade::component('bsPassword', 'components.form.input', ['name', 'attributes' => [], 'value' => '', 'type' => 'password']);
23
        FormFacade::component('bsFile', 'components.form.input', ['name', 'attributes' => [], 'value' => null, 'type' => 'file']);
24
        FormFacade::component('bsTextarea', 'components.form.textarea', ['name', 'value' => null, 'attributes' => []]);
25
        FormFacade::component('bsSelect', 'components.form.select', ['name', 'list' => [], 'selected' => null, 'attributes' => []]);
26
        FormFacade::component('bsCheckbox', 'components.form.custom-control', ['name', 'description', 'value' => null, 'type' => 'checkbox']);
27
        HtmlFacade::macro('asset', function ($manifestName, $path) {
28
            static $manifest;
29
            $basePath = app()->environment('production') ? 'dist' : 'build';
0 ignored issues
show
introduced by
The method environment() does not exist on Illuminate\Container\Container. Are you sure you never get this type here, but always one of the subclasses? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

29
            $basePath = app()->/** @scrutinizer ignore-call */ environment('production') ? 'dist' : 'build';
Loading history...
30
            if (! $manifest
31
                && file_exists($manifestPath = public_path("{$basePath}/manifest-{$manifestName}.json"))
32
            ) {
33
                $manifest = json_decode(file_get_contents($manifestPath), true);
34
            }
35
            if ($manifest && isset($manifest[$path])) {
36
                return $manifest[$path];
37
            }
38
        });
39
        /*
40
         * Prepare flash message for alerts
41
         */
42
        View::composer('partials/messages', function (\Illuminate\View\View $view) {
43
            $data = collect($view->getData());
44
            if ($flash = session()->get('flash_message') ?: $data->get('flashMessage')) {
45
                $view->with('flashMessage', $flash);
46
                $view->with('flashType', 'info');
47
            } elseif ($flash = session()->get('flash_success') ?: $data->get('flashSuccess')) {
48
                $view->with('flashMessage', $flash);
49
                $view->with('flashType', 'success');
50
            } elseif ($flash = session()->get('flash_info') ?: $data->get('flashInfo')) {
51
                $view->with('flashMessage', $flash);
52
                $view->with('flashType', 'info');
53
            } elseif ($flash = session()->get('flash_warning') ?: $data->get('flashWarning')) {
54
                $view->with('flashMessage', $flash);
55
                $view->with('flashType', 'warning');
56
            } elseif ($flash = session()->get('flash_danger') ?: $data->get('flashDanger')) {
57
                $view->with('flashMessage', $flash);
58
                $view->with('flashType', 'danger');
59
            } elseif ($flash = session()->get('flash_error') ?: $data->get('flashError')) {
60
                $view->with('flashMessage', $flash);
61
                $view->with('flashType', 'danger');
62
            }
63
        });
64
        View::composer('*', function (\Illuminate\View\View $view) {
65
            $view->with('loggedInUser', auth()->user());
66
        });
67
    }
68
69
    /**
70
     * Register the application services.
71
     */
72
    public function register()
73
    {
74
    }
75
}
76