Conditions | 15 |
Paths | 16384 |
Total Lines | 63 |
Code Lines | 32 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
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 |
||
113 | public static function decode(Buffer $data) |
||
114 | { |
||
115 | $flags = Value\ShortValue::decode($data); |
||
116 | $properties = []; |
||
117 | |||
118 | if ($flags & 32768) { |
||
119 | $properties['content-type'] = Value\ShortStringValue::decode($data); |
||
120 | } |
||
121 | |||
122 | if ($flags & 16384) { |
||
123 | $properties['content-encoding'] = Value\ShortStringValue::decode($data); |
||
124 | } |
||
125 | |||
126 | if ($flags & 8192) { |
||
127 | $properties['headers'] = Value\TableValue::decode($data); |
||
128 | } |
||
129 | |||
130 | if ($flags & 4096) { |
||
131 | $properties['delivery-mode'] = Value\OctetValue::decode($data); |
||
132 | } |
||
133 | |||
134 | if ($flags & 2048) { |
||
135 | $properties['priority'] = Value\OctetValue::decode($data); |
||
136 | } |
||
137 | |||
138 | if ($flags & 1024) { |
||
139 | $properties['correlation-id'] = Value\ShortStringValue::decode($data); |
||
140 | } |
||
141 | |||
142 | if ($flags & 512) { |
||
143 | $properties['reply-to'] = Value\ShortStringValue::decode($data); |
||
144 | } |
||
145 | |||
146 | if ($flags & 256) { |
||
147 | $properties['expiration'] = Value\ShortStringValue::decode($data); |
||
148 | } |
||
149 | |||
150 | if ($flags & 128) { |
||
151 | $properties['message-id'] = Value\ShortStringValue::decode($data); |
||
152 | } |
||
153 | |||
154 | if ($flags & 64) { |
||
155 | $properties['timestamp'] = Value\LongLongValue::decode($data); |
||
156 | } |
||
157 | |||
158 | if ($flags & 32) { |
||
159 | $properties['type'] = Value\ShortStringValue::decode($data); |
||
160 | } |
||
161 | |||
162 | if ($flags & 16) { |
||
163 | $properties['user-id'] = Value\ShortStringValue::decode($data); |
||
164 | } |
||
165 | |||
166 | if ($flags & 8) { |
||
167 | $properties['app-id'] = Value\ShortStringValue::decode($data); |
||
168 | } |
||
169 | |||
170 | if ($flags & 4) { |
||
171 | $properties['reserved'] = Value\ShortStringValue::decode($data); |
||
172 | } |
||
173 | |||
174 | return $properties; |
||
175 | } |
||
176 | } |
||
177 |