| Conditions | 4 |
| Paths | 3 |
| Total Lines | 18 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 21 | public static function parseUserNick($userId = null, $onEmpty = 'unknown') |
||
| 22 | { |
||
| 23 | // try to get user id as integer |
||
| 24 | if (Obj::isLikeInt($userId)) { |
||
| 25 | $userId = (int)$userId; |
||
| 26 | } else { // user id is empty, lets return default value |
||
| 27 | return \App::$Security->strip_tags($onEmpty); |
||
| 28 | } |
||
| 29 | |||
| 30 | // try to find user active record as object |
||
| 31 | $identity = App::$User->identity($userId); |
||
| 32 | if ($identity === null || $identity === false) { |
||
| 33 | return \App::$Security->strip_tags($onEmpty); |
||
| 34 | } |
||
| 35 | |||
| 36 | // return user nickname from profile |
||
| 37 | return $identity->getProfile()->getNickname(); |
||
| 38 | } |
||
| 39 | |||
| 40 | } |