Total Complexity | 9 |
Total Lines | 108 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
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() |
||
115 | } |
||
116 | } |