| Conditions | 7 |
| Paths | 12 |
| Total Lines | 20 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 9.2312 |
| Changes | 0 | ||
| 1 | <?php |
||
| 36 | 19 | public function execute($user, $item, $params) |
|
| 37 | { |
||
| 38 | 19 | $class = Yii::$app->user->identityClass; |
|
| 39 | 19 | if (is_numeric($user) || is_int($user)) { |
|
| 40 | $user = $class::find()->id($user)->one(); |
||
| 41 | } |
||
| 42 | 19 | if (is_string($user)) { |
|
| 43 | $user = $class::find()->guid($user)->one(); |
||
| 44 | } |
||
| 45 | 19 | $organization = $params['organization']; |
|
| 46 | /* @var $organization Organization */// The Organization or department which is parent. |
||
| 47 | // If current user is creator of organization or department, he is allowed to set up a child. |
||
| 48 | 19 | if (!$user->isOrganizationCreator($organization) && !$user->isOrganizationAdministrator($organization)) { |
|
| 49 | return false; |
||
| 50 | } |
||
| 51 | 19 | if ($organization->hasReachedSubordinateLimit()) { |
|
| 52 | 1 | return false; |
|
| 53 | } |
||
| 54 | 19 | return true; |
|
| 55 | } |
||
| 56 | } |
||
| 57 |