| Conditions | 3 |
| Paths | 3 |
| Total Lines | 19 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 3.054 |
| Changes | 0 | ||
| 1 | <?php |
||
| 96 | 2 | public function getByAppName(string $role, Companies $company): Roles |
|
| 97 | { |
||
| 98 | //echeck if we have a dot , taht means we are sending the specific app to use |
||
| 99 | 2 | if (strpos($role, '.') == false) { |
|
| 100 | throw new ServerErrorHttpException('ACL - We are expecting the app for this role'); |
||
| 101 | } |
||
| 102 | |||
| 103 | 2 | $appRole = explode('.', $role); |
|
| 104 | 2 | $role = $appRole[1]; |
|
|
1 ignored issue
–
show
|
|||
| 105 | 2 | $appName = $appRole[0]; |
|
| 106 | |||
| 107 | //look for the app and set it |
||
| 108 | 2 | if (!$app = Apps::getACLApp($appName)) { |
|
| 109 | throw new ServerErrorHttpException('ACL - No app found for this role'); |
||
| 110 | } |
||
| 111 | |||
| 112 | 2 | return self::findFirst([ |
|
|
1 ignored issue
–
show
|
|||
| 113 | 2 | 'conditions' => 'apps_id in (?0, ?1) AND company_id in (?2 , ?3)', |
|
| 114 | 2 | 'bind' => [$app->getId(), self::DEFAULT_ACL_APP_ID, $company->getId(), self::DEFAULT_ACL_COMPANY_ID] |
|
| 115 | ]); |
||
| 118 |
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: