Conditions | 3 |
Paths | 3 |
Total Lines | 19 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 3.054 |
Changes | 0 |
1 | <?php |
||
103 | 6 | public static function getByAppName(string $role, BakaCompanies $company): Roles |
|
104 | { |
||
105 | //echeck if we have a dot , taht means we are sending the specific app to use |
||
106 | 6 | if (strpos($role, '.') === false) { |
|
107 | throw new ServerErrorHttpException('ACL - We are expecting the app for this role'); |
||
108 | } |
||
109 | |||
110 | 6 | $appRole = explode('.', $role); |
|
111 | 6 | $role = $appRole[1]; |
|
1 ignored issue
–
show
|
|||
112 | 6 | $appName = $appRole[0]; |
|
113 | |||
114 | //look for the app and set it |
||
115 | 6 | if (!$app = Apps::getACLApp($appName)) { |
|
116 | throw new ServerErrorHttpException('ACL - No app found for this role'); |
||
117 | } |
||
118 | |||
119 | 6 | return self::findFirst([ |
|
120 | 6 | 'conditions' => 'apps_id in (?0, ?1) AND company_id in (?2 , ?3)', |
|
121 | 6 | 'bind' => [$app->getId(), self::DEFAULT_ACL_APP_ID, $company->getId(), self::DEFAULT_ACL_COMPANY_ID] |
|
122 | ]); |
||
125 |