Conditions | 47 |
Total Lines | 144 |
Code Lines | 95 |
Lines | 0 |
Ratio | 0 % |
Changes | 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 |
||
185 | public function normalize($object, $format = null, array $context = []) |
||
186 | { |
||
187 | $data = new \stdClass(); |
||
188 | if (null !== $object->getLastExecutedScanTaskId()) { |
||
189 | $data->{'LastExecutedScanTaskId'} = $object->getLastExecutedScanTaskId(); |
||
190 | } |
||
191 | if (null !== $object->getLastExecutionError()) { |
||
192 | $data->{'LastExecutionError'} = $object->getLastExecutionError(); |
||
193 | } |
||
194 | if (null !== $object->getLastExecutionStatus()) { |
||
195 | $data->{'LastExecutionStatus'} = $object->getLastExecutionStatus(); |
||
196 | } |
||
197 | if (null !== $object->getTimeWindow()) { |
||
198 | $data->{'TimeWindow'} = $this->normalizer->normalize($object->getTimeWindow(), 'json', $context); |
||
199 | } |
||
200 | if (null !== $object->getId()) { |
||
201 | $data->{'Id'} = $object->getId(); |
||
202 | } |
||
203 | if (null !== $object->getOccurencesCount()) { |
||
204 | $data->{'OccurencesCount'} = $object->getOccurencesCount(); |
||
205 | } |
||
206 | if (null !== $object->getDisabled()) { |
||
207 | $data->{'Disabled'} = $object->getDisabled(); |
||
208 | } |
||
209 | if (null !== $object->getEnableScheduling()) { |
||
210 | $data->{'EnableScheduling'} = $object->getEnableScheduling(); |
||
211 | } |
||
212 | if (null !== $object->getName()) { |
||
213 | $data->{'Name'} = $object->getName(); |
||
214 | } |
||
215 | if (null !== $object->getNextExecutionTime()) { |
||
216 | $data->{'NextExecutionTime'} = $object->getNextExecutionTime(); |
||
217 | } |
||
218 | if (null !== $object->getScanGroupId()) { |
||
219 | $data->{'ScanGroupId'} = $object->getScanGroupId(); |
||
220 | } |
||
221 | if (null !== $object->getScanType()) { |
||
222 | $data->{'ScanType'} = $object->getScanType(); |
||
223 | } |
||
224 | if (null !== $object->getScheduleRunType()) { |
||
225 | $data->{'ScheduleRunType'} = $object->getScheduleRunType(); |
||
226 | } |
||
227 | if (null !== $object->getCustomRecurrence()) { |
||
228 | $data->{'CustomRecurrence'} = $this->normalizer->normalize($object->getCustomRecurrence(), 'json', $context); |
||
229 | } |
||
230 | if (null !== $object->getIsTargetUrlRequired()) { |
||
231 | $data->{'IsTargetUrlRequired'} = $object->getIsTargetUrlRequired(); |
||
232 | } |
||
233 | if (null !== $object->getAdditionalWebsites()) { |
||
234 | $data->{'AdditionalWebsites'} = $this->normalizer->normalize($object->getAdditionalWebsites(), 'json', $context); |
||
235 | } |
||
236 | if (null !== $object->getAgentGroupId()) { |
||
237 | $data->{'AgentGroupId'} = $object->getAgentGroupId(); |
||
238 | } |
||
239 | if (null !== $object->getAgentId()) { |
||
240 | $data->{'AgentId'} = $object->getAgentId(); |
||
241 | } |
||
242 | if (null !== $object->getBasicAuthenticationSetting()) { |
||
243 | $data->{'BasicAuthenticationSetting'} = $this->normalizer->normalize($object->getBasicAuthenticationSetting(), 'json', $context); |
||
244 | } |
||
245 | if (null !== $object->getCanEdit()) { |
||
246 | $data->{'CanEdit'} = $object->getCanEdit(); |
||
247 | } |
||
248 | if (null !== $object->getClientCertificateAuthentication()) { |
||
249 | $data->{'ClientCertificateAuthentication'} = $this->normalizer->normalize($object->getClientCertificateAuthentication(), 'json', $context); |
||
250 | } |
||
251 | if (null !== $object->getCookies()) { |
||
252 | $data->{'Cookies'} = $object->getCookies(); |
||
253 | } |
||
254 | if (null !== $object->getCrawlAndAttack()) { |
||
255 | $data->{'CrawlAndAttack'} = $object->getCrawlAndAttack(); |
||
256 | } |
||
257 | if (null !== $object->getCreateType()) { |
||
258 | $data->{'CreateType'} = $object->getCreateType(); |
||
259 | } |
||
260 | if (null !== $object->getFindAndFollowNewLinks()) { |
||
261 | $data->{'FindAndFollowNewLinks'} = $object->getFindAndFollowNewLinks(); |
||
262 | } |
||
263 | if (null !== $object->getFormAuthenticationSetting()) { |
||
264 | $data->{'FormAuthenticationSetting'} = $this->normalizer->normalize($object->getFormAuthenticationSetting(), 'json', $context); |
||
265 | } |
||
266 | if (null !== $object->getHeaderAuthentication()) { |
||
267 | $data->{'HeaderAuthentication'} = $this->normalizer->normalize($object->getHeaderAuthentication(), 'json', $context); |
||
268 | } |
||
269 | if (null !== $object->getImportedLinks()) { |
||
270 | $data->{'ImportedLinks'} = $this->normalizer->normalize($object->getImportedLinks(), 'json', $context); |
||
271 | } |
||
272 | if (null !== $object->getIsMaxScanDurationEnabled()) { |
||
273 | $data->{'IsMaxScanDurationEnabled'} = $object->getIsMaxScanDurationEnabled(); |
||
274 | } |
||
275 | if (null !== $object->getIsPrimary()) { |
||
276 | $data->{'IsPrimary'} = $object->getIsPrimary(); |
||
277 | } |
||
278 | if (null !== $object->getIsShared()) { |
||
279 | $data->{'IsShared'} = $object->getIsShared(); |
||
280 | } |
||
281 | if (null !== $object->getMaxScanDuration()) { |
||
282 | $data->{'MaxScanDuration'} = $object->getMaxScanDuration(); |
||
283 | } |
||
284 | if (null !== $object->getPolicyId()) { |
||
285 | $data->{'PolicyId'} = $object->getPolicyId(); |
||
286 | } |
||
287 | if (null !== $object->getProfileId()) { |
||
288 | $data->{'ProfileId'} = $object->getProfileId(); |
||
289 | } |
||
290 | if (null !== $object->getProfileName()) { |
||
291 | $data->{'ProfileName'} = $object->getProfileName(); |
||
292 | } |
||
293 | if (null !== $object->getReportPolicyId()) { |
||
294 | $data->{'ReportPolicyId'} = $object->getReportPolicyId(); |
||
295 | } |
||
296 | if (null !== $object->getSaveScanProfile()) { |
||
297 | $data->{'SaveScanProfile'} = $object->getSaveScanProfile(); |
||
298 | } |
||
299 | if (null !== $object->getScopeSetting()) { |
||
300 | $data->{'ScopeSetting'} = $this->normalizer->normalize($object->getScopeSetting(), 'json', $context); |
||
301 | } |
||
302 | if (null !== $object->getSelectedAgents()) { |
||
303 | $values = []; |
||
304 | foreach ($object->getSelectedAgents() as $value) { |
||
305 | $values[] = $this->normalizer->normalize($value, 'json', $context); |
||
306 | } |
||
307 | $data->{'SelectedAgents'} = $values; |
||
308 | } |
||
309 | if (null !== $object->getSelectedScanProfileId()) { |
||
310 | $data->{'SelectedScanProfileId'} = $object->getSelectedScanProfileId(); |
||
311 | } |
||
312 | if (null !== $object->getSelectedScanProfileName()) { |
||
313 | $data->{'SelectedScanProfileName'} = $object->getSelectedScanProfileName(); |
||
314 | } |
||
315 | if (null !== $object->getTargetUrl()) { |
||
316 | $data->{'TargetUrl'} = $object->getTargetUrl(); |
||
317 | } |
||
318 | if (null !== $object->getUrlRewriteSetting()) { |
||
319 | $data->{'UrlRewriteSetting'} = $this->normalizer->normalize($object->getUrlRewriteSetting(), 'json', $context); |
||
320 | } |
||
321 | if (null !== $object->getUserId()) { |
||
322 | $data->{'UserId'} = $object->getUserId(); |
||
323 | } |
||
324 | if (null !== $object->getWebsiteGroupId()) { |
||
325 | $data->{'WebsiteGroupId'} = $object->getWebsiteGroupId(); |
||
326 | } |
||
327 | |||
328 | return $data; |
||
329 | } |
||
331 |