| Conditions | 5 |
| Paths | 5 |
| Total Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 30 |
| Changes | 0 | ||
| 1 | <?php |
||
| 25 | public static function resolveUser($user) |
||
| 26 | { |
||
| 27 | if ($user instanceof IdentityInterface) { |
||
| 28 | return $user; |
||
| 29 | } |
||
| 30 | |||
| 31 | if ($user === 'CURRENT_USER') { |
||
| 32 | return Craft::$app->getUser()->getIdentity(); |
||
| 33 | } |
||
| 34 | |||
| 35 | if (is_numeric($user)) { |
||
| 36 | return Craft::$app->getUsers()->getUserById($user); |
||
| 37 | } |
||
| 38 | |||
| 39 | if (is_string($user)) { |
||
| 40 | return Craft::$app->getUsers()->getUserByUsernameOrEmail($user); |
||
| 41 | } |
||
| 42 | |||
| 43 | return null; |
||
| 44 | } |
||
| 45 | } |
||
| 46 |