Test Setup Failed
Push — master ( 239ff9...5e0470 )
by Php Easy Api
03:53
created

RoleManager::getPermission()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 1
c 1
b 1
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Resta\Role;
4
5
use Resta\Foundation\ApplicationProvider;
6
7
class RoleManager extends ApplicationProvider implements RoleInterface
8
{
9
    /**
10
     * @var string
11
     */
12
    protected $adapter = 'Database';
13
14
    /**
15
     * @var string
16
     */
17
    protected $resource = 'Resta\\Role\\Resource';
18
19
    /**
20
     * @var string
21
     */
22
    protected $routeName;
23
24
    /**
25
     * passing directly
26
     *
27
     * @return bool
28
     */
29
    public function directly()
30
    {
31
        return true;
32
    }
33
34
    /**
35
     * get resource path
36
     *
37
     * @return string
38
     */
39
    public function getAdapter()
40
    {
41
        return $this->adapter;
42
    }
43
44
    /**
45
     * get resource path
46
     *
47
     * @return string
48
     */
49
    public function getResource()
50
    {
51
        return $this->resource;
52
    }
53
54
    /**
55
     * @return bool
56
     */
57
    public function make()
58
    {
59
        $permission = $this->getPermission();
60
61
        $routeNames = $permission::roleMake($this->routeName);
62
63
        if($routeNames->count()){
64
            return true;
65
        }
66
67
        return false;
68
    }
69
70
    /**
71
     * route name for role manager
72
     * 
73
     * @param $name
74
     * @return $this
75
     */
76
    public function routeName($name)
77
    {
78
        $this->routeName = $name;
79
        
80
        return $this;
81
    }
82
83
    /**
84
     * set adapter name
85
     *
86
     * @param string $adapter
87
     * @return RoleManager
88
     */
89
    public function setAdapter($adapter='Database')
90
    {
91
        $this->adapter = $adapter;
92
93
        return $this;
94
    }
95
96
    /**
97
     * set resource path
98
     *
99
     * @param $resource
100
     * @return void
101
     */
102
    public function setResource($resource)
103
    {
104
        $this->resource = $resource;
105
    }
106
107
    /**
108
     * get permission
109
     *
110
     * @return string
111
     */
112
    private function getPermission()
113
    {
114
        return $this->getResource().'\\'.$this->getAdapter().'\Permission';
115
    }
116
}