| Conditions | 11 | 
| Paths | 32 | 
| Total Lines | 39 | 
| Code Lines | 23 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 4 | ||
| Bugs | 0 | Features | 0 | 
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php | ||
| 78 | } | ||
| 79 | $data[$item] = _json_decode( | ||
| 80 | $this->db()->qfs( | ||
| 81 | "SELECT `value` | ||
| 82 | FROM `[prefix]users_data` | ||
| 83 | WHERE | ||
| 84 | `id` = '$user' AND | ||
| 85 | `item` = '%s'", | ||
| 86 | $item | ||
| 87 | ) | ||
| 88 | ); | ||
| 89 | 			if ($data[$item] === null) { | ||
| 90 | $data[$item] = false; | ||
| 91 | } | ||
| 92 | 			$this->cache->{"data/$user"} = $data; | ||
| 93 | } | ||
| 94 | return $data[$item]; | ||
| 95 | } | ||
| 96 | /** | ||
| 97 | * Setting additional data item(s) of specified user | ||
| 98 | * | ||
| 99 | * @param array|string $item Item-value array may be specified for setting several items at once | ||
| 100 | * @param mixed|null $value | ||
| 101 | * @param false|int $user If not specified - current user assumed | ||
| 102 | * | ||
| 103 | * @return bool | ||
| 104 | */ | ||
| 105 | 	function set_data ($item, $value = null, $user = false) { | ||
| 106 | $user = (int)$user ?: $this->id; | ||
| 107 | 		if (!$item || $user == User::GUEST_ID) { | ||
| 108 | return false; | ||
| 109 | } | ||
| 110 | 		if (!is_array($item)) { | ||
| 111 | $item = [ | ||
| 112 | $item => $value | ||
| 113 | ]; | ||
| 114 | } | ||
| 115 | $params = []; | ||
| 116 | 		foreach ($item as $i => $v) { | ||
| 117 | $params[] = [$i, _json_encode($v)]; | ||
| 163 |