ShareMethods   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 24
c 2
b 1
f 0
dl 0
loc 39
rs 10
wmc 8

1 Method

Rating   Name   Duplication   Size   Complexity  
B shareMethods() 0 33 8
1
<?php
2
3
namespace Larrock\Core\Traits;
4
5
trait ShareMethods
6
{
7
    /**
8
     * Расшаривание переменных в шаблон, указывающих на использование методов управления контентом
9
     * @return array
10
     */
11
    public function shareMethods()
12
    {
13
        $allowed = [];
14
        if (method_exists($this, 'create')) {
15
            \View::share('allowCreate', true);
0 ignored issues
show
Bug introduced by
'allowCreate' of type string is incompatible with the type array expected by parameter $| of Illuminate\Support\Facades\View::share(). ( Ignorable by Annotation )

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

15
            \View::share(/** @scrutinizer ignore-type */ 'allowCreate', true);
Loading history...
16
            $allowed[] = 'allowCreate';
17
        }
18
        if (method_exists($this, 'index')) {
19
            \View::share('allowIndex', true);
20
            $allowed[] = 'allowIndex';
21
        }
22
        if (method_exists($this, 'store')) {
23
            \View::share('allowStore', true);
24
            $allowed[] = 'allowStore';
25
        }
26
        if (method_exists($this, 'destroy')) {
27
            \View::share('allowDestroy', true);
28
            $allowed[] = 'allowDestroy';
29
        }
30
        if (method_exists($this, 'edit')) {
31
            \View::share('allowEdit', true);
32
            $allowed[] = 'allowEdit';
33
        }
34
        if (method_exists($this, 'update')) {
35
            \View::share('allowUpdate', true);
36
            $allowed[] = 'allowUpdate';
37
        }
38
        if (method_exists($this, 'show')) {
39
            \View::share('allowShow', true);
40
            $allowed[] = 'allowShow';
41
        }
42
43
        return $allowed;
44
    }
45
}
46