Code Duplication    Length = 12-13 lines in 4 locations

src/Directives/PermissionDirectives.php 4 locations

@@ 20-32 (lines=13) @@
17
        $this->bladeCompiler = $bladeCompiler;
18
    }
19
20
    public function role_directive()
21
    {
22
        $this->bladeCompiler->directive('role', function ($arguments) {
23
            $arguments = preg_replace('(\(|\)| )', '', $arguments);
24
            list($role, $guard) = \explode(',', $arguments . ',');
25
26
            return "<?php if(auth({$guard})->check() && auth({$guard})->user()->hasRole({$role})): ?>";
27
        });
28
29
        $this->bladeCompiler->directive('endrole', function () {
30
            return '<?php endif; ?>';
31
        });
32
    }
33
34
    public function hasrole_directive()
35
    {
@@ 34-45 (lines=12) @@
31
        });
32
    }
33
34
    public function hasrole_directive()
35
    {
36
        $this->bladeCompiler->directive('hasrole', function ($arguments) {
37
            $arguments = preg_replace('(\(|\)| )', '', $arguments);
38
            list($role, $guard) = \explode(',', $arguments . ',');
39
40
            return "<?php if(auth({$guard})->check() && auth({$guard})->user()->hasRole({$role})): ?>";
41
        });
42
        $this->bladeCompiler->directive('endhasrole', function () {
43
            return '<?php endif; ?>';
44
        });
45
    }
46
47
    public function hasanyrole_directive()
48
    {
@@ 47-58 (lines=12) @@
44
        });
45
    }
46
47
    public function hasanyrole_directive()
48
    {
49
        $this->bladeCompiler->directive('hasanyrole', function ($arguments) {
50
            $arguments = preg_replace('(\(|\)| )', '', $arguments);
51
            list($roles, $guard) = \explode(',', $arguments . ',');
52
53
            return "<?php if(auth({$guard})->check() && auth({$guard})->user()->hasAnyRole({$roles})): ?>";
54
        });
55
        $this->bladeCompiler->directive('endhasanyrole', function () {
56
            return '<?php endif; ?>';
57
        });
58
    }
59
60
    public function hasallroles_directive()
61
    {
@@ 60-71 (lines=12) @@
57
        });
58
    }
59
60
    public function hasallroles_directive()
61
    {
62
        $this->bladeCompiler->directive('hasallroles', function ($arguments) {
63
            $arguments = preg_replace('(\(|\)| )', '', $arguments);
64
            list($roles, $guard) = \explode(',', $arguments . ',');
65
66
            return "<?php if(auth({$guard})->check() && auth({$guard})->user()->hasAllRoles({$roles})): ?>";
67
        });
68
        $this->bladeCompiler->directive('endhasallroles', function () {
69
            return '<?php endif; ?>';
70
        });
71
    }
72
}