| Conditions | 4 |
| Paths | 4 |
| Total Lines | 30 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| 1 | <?php |
||
| 16 | public static function findById($id) |
||
|
|
|||
| 17 | { |
||
| 18 | if (!isset(static::$identity_map[$id])) { |
||
| 19 | $cache_key = static::className() . ':' . $id; |
||
| 20 | |||
| 21 | static::$identity_map[$id] = Yii::$app->cache->get($cache_key); |
||
| 22 | if (static::$identity_map[$id] === false) { |
||
| 23 | static::$identity_map[$id] = static::findOne($id); |
||
| 24 | |||
| 25 | if (is_object(static::$identity_map[$id])) { |
||
| 26 | |||
| 27 | Yii::$app->cache->set( |
||
| 28 | static::className() . ":" . $id, |
||
| 29 | static::$identity_map[$id], |
||
| 30 | 86400, |
||
| 31 | new TagDependency( |
||
| 32 | [ |
||
| 33 | 'tags' => [ |
||
| 34 | \devgroup\TagDependencyHelper\ActiveRecordHelper::getObjectTag(static::className(), static::$identity_map[$id]->id), |
||
| 35 | ], |
||
| 36 | ] |
||
| 37 | ) |
||
| 38 | ); |
||
| 39 | } |
||
| 40 | } |
||
| 41 | |||
| 42 | return static::$identity_map[$id]; |
||
| 43 | } |
||
| 44 | return static::$identity_map[$id]; |
||
| 45 | } |
||
| 46 | } |
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.