| Conditions | 4 |
| Paths | 5 |
| Total Lines | 26 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 4 | protected function activate($id) |
||
|
|
|||
| 5 | { |
||
| 6 | $redis = Yii::app()->redis->getClient(); |
||
| 7 | $saved = $redis->sadd('badges:owned:'.$this->uid, $id); |
||
| 8 | if ($saved) { |
||
| 9 | //save the actual timestamp |
||
| 10 | $redis->zadd('badges:added:'.$this->uid, time(), $id); |
||
| 11 | |||
| 12 | $badge = $this->getBadge($id); |
||
| 13 | |||
| 14 | $score = 1; |
||
| 15 | |||
| 16 | if ($badge['level'] == self::LEVEL_SILVER) { |
||
| 17 | $score = 3; |
||
| 18 | } |
||
| 19 | |||
| 20 | if ($badge['level'] == self::LEVEL_GOLD) { |
||
| 21 | $score = 9; |
||
| 22 | } |
||
| 23 | |||
| 24 | $redis->zIncrBy("badges:leaderboard", $score, $this->uid); |
||
| 25 | |||
| 26 | $this->postToWall($badge); |
||
| 27 | } |
||
| 28 | return $saved; |
||
| 29 | } |
||
| 30 | |||
| 39 |
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@returnannotation as described here.