| Conditions | 43 |
| Total Lines | 137 |
| Code Lines | 92 |
| 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 |
||
| 178 | public function normalize($object, $format = null, array $context = []) |
||
| 179 | { |
||
| 180 | $data = new \stdClass(); |
||
| 181 | if (null !== $object->getAgentGroupId()) { |
||
| 182 | $data->{'AgentGroupId'} = $object->getAgentGroupId(); |
||
| 183 | } |
||
| 184 | if (null !== $object->getAgentId()) { |
||
| 185 | $data->{'AgentId'} = $object->getAgentId(); |
||
| 186 | } |
||
| 187 | if (null !== $object->getCreateType()) { |
||
| 188 | $data->{'CreateType'} = $object->getCreateType(); |
||
| 189 | } |
||
| 190 | if (null !== $object->getIsPrimary()) { |
||
| 191 | $data->{'IsPrimary'} = $object->getIsPrimary(); |
||
| 192 | } |
||
| 193 | if (null !== $object->getIsShared()) { |
||
| 194 | $data->{'IsShared'} = $object->getIsShared(); |
||
| 195 | } |
||
| 196 | if (null !== $object->getIsTimeWindowEnabled()) { |
||
| 197 | $data->{'IsTimeWindowEnabled'} = $object->getIsTimeWindowEnabled(); |
||
| 198 | } |
||
| 199 | if (null !== $object->getPolicyId()) { |
||
| 200 | $data->{'PolicyId'} = $object->getPolicyId(); |
||
| 201 | } |
||
| 202 | if (null !== $object->getProfileId()) { |
||
| 203 | $data->{'ProfileId'} = $object->getProfileId(); |
||
| 204 | } |
||
| 205 | if (null !== $object->getProfileName()) { |
||
| 206 | $data->{'ProfileName'} = $object->getProfileName(); |
||
| 207 | } |
||
| 208 | if (null !== $object->getReportPolicyId()) { |
||
| 209 | $data->{'ReportPolicyId'} = $object->getReportPolicyId(); |
||
| 210 | } |
||
| 211 | if (null !== $object->getTargetUri()) { |
||
| 212 | $data->{'TargetUri'} = $object->getTargetUri(); |
||
| 213 | } |
||
| 214 | if (null !== $object->getUserId()) { |
||
| 215 | $data->{'UserId'} = $object->getUserId(); |
||
| 216 | } |
||
| 217 | if (null !== $object->getAdditionalWebsites()) { |
||
| 218 | $values = []; |
||
| 219 | foreach ($object->getAdditionalWebsites() as $value) { |
||
| 220 | $values[] = $this->normalizer->normalize($value, 'json', $context); |
||
| 221 | } |
||
| 222 | $data->{'AdditionalWebsites'} = $values; |
||
| 223 | } |
||
| 224 | if (null !== $object->getBasicAuthenticationApiModel()) { |
||
| 225 | $data->{'BasicAuthenticationApiModel'} = $this->normalizer->normalize($object->getBasicAuthenticationApiModel(), 'json', $context); |
||
| 226 | } |
||
| 227 | if (null !== $object->getClientCertificateAuthenticationSetting()) { |
||
| 228 | $data->{'ClientCertificateAuthenticationSetting'} = $this->normalizer->normalize($object->getClientCertificateAuthenticationSetting(), 'json', $context); |
||
| 229 | } |
||
| 230 | if (null !== $object->getCookies()) { |
||
| 231 | $data->{'Cookies'} = $object->getCookies(); |
||
| 232 | } |
||
| 233 | if (null !== $object->getCrawlAndAttack()) { |
||
| 234 | $data->{'CrawlAndAttack'} = $object->getCrawlAndAttack(); |
||
| 235 | } |
||
| 236 | if (null !== $object->getEnableHeuristicChecksInCustomUrlRewrite()) { |
||
| 237 | $data->{'EnableHeuristicChecksInCustomUrlRewrite'} = $object->getEnableHeuristicChecksInCustomUrlRewrite(); |
||
| 238 | } |
||
| 239 | if (null !== $object->getExcludedLinks()) { |
||
| 240 | $values_1 = []; |
||
| 241 | foreach ($object->getExcludedLinks() as $value_1) { |
||
| 242 | $values_1[] = $this->normalizer->normalize($value_1, 'json', $context); |
||
| 243 | } |
||
| 244 | $data->{'ExcludedLinks'} = $values_1; |
||
| 245 | } |
||
| 246 | if (null !== $object->getDisallowedHttpMethods()) { |
||
| 247 | $values_2 = []; |
||
| 248 | foreach ($object->getDisallowedHttpMethods() as $value_2) { |
||
| 249 | $values_2[] = $value_2; |
||
| 250 | } |
||
| 251 | $data->{'DisallowedHttpMethods'} = $values_2; |
||
| 252 | } |
||
| 253 | if (null !== $object->getExcludeLinks()) { |
||
| 254 | $data->{'ExcludeLinks'} = $object->getExcludeLinks(); |
||
| 255 | } |
||
| 256 | if (null !== $object->getFindAndFollowNewLinks()) { |
||
| 257 | $data->{'FindAndFollowNewLinks'} = $object->getFindAndFollowNewLinks(); |
||
| 258 | } |
||
| 259 | if (null !== $object->getFormAuthenticationSettingModel()) { |
||
| 260 | $data->{'FormAuthenticationSettingModel'} = $this->normalizer->normalize($object->getFormAuthenticationSettingModel(), 'json', $context); |
||
| 261 | } |
||
| 262 | if (null !== $object->getHeaderAuthentication()) { |
||
| 263 | $data->{'HeaderAuthentication'} = $this->normalizer->normalize($object->getHeaderAuthentication(), 'json', $context); |
||
| 264 | } |
||
| 265 | if (null !== $object->getImportedLinks()) { |
||
| 266 | $values_3 = []; |
||
| 267 | foreach ($object->getImportedLinks() as $value_3) { |
||
| 268 | $values_3[] = $value_3; |
||
| 269 | } |
||
| 270 | $data->{'ImportedLinks'} = $values_3; |
||
| 271 | } |
||
| 272 | if (null !== $object->getImportedFiles()) { |
||
| 273 | $values_4 = []; |
||
| 274 | foreach ($object->getImportedFiles() as $value_4) { |
||
| 275 | $values_4[] = $this->normalizer->normalize($value_4, 'json', $context); |
||
| 276 | } |
||
| 277 | $data->{'ImportedFiles'} = $values_4; |
||
| 278 | } |
||
| 279 | if (null !== $object->getIsMaxScanDurationEnabled()) { |
||
| 280 | $data->{'IsMaxScanDurationEnabled'} = $object->getIsMaxScanDurationEnabled(); |
||
| 281 | } |
||
| 282 | if (null !== $object->getMaxDynamicSignatures()) { |
||
| 283 | $data->{'MaxDynamicSignatures'} = $object->getMaxDynamicSignatures(); |
||
| 284 | } |
||
| 285 | if (null !== $object->getMaxScanDuration()) { |
||
| 286 | $data->{'MaxScanDuration'} = $object->getMaxScanDuration(); |
||
| 287 | } |
||
| 288 | if (null !== $object->getScope()) { |
||
| 289 | $data->{'Scope'} = $object->getScope(); |
||
| 290 | } |
||
| 291 | if (null !== $object->getSubPathMaxDynamicSignatures()) { |
||
| 292 | $data->{'SubPathMaxDynamicSignatures'} = $object->getSubPathMaxDynamicSignatures(); |
||
| 293 | } |
||
| 294 | if (null !== $object->getTimeWindow()) { |
||
| 295 | $data->{'TimeWindow'} = $this->normalizer->normalize($object->getTimeWindow(), 'json', $context); |
||
| 296 | } |
||
| 297 | if (null !== $object->getUrlRewriteAnalyzableExtensions()) { |
||
| 298 | $data->{'UrlRewriteAnalyzableExtensions'} = $object->getUrlRewriteAnalyzableExtensions(); |
||
| 299 | } |
||
| 300 | if (null !== $object->getUrlRewriteBlockSeparators()) { |
||
| 301 | $data->{'UrlRewriteBlockSeparators'} = $object->getUrlRewriteBlockSeparators(); |
||
| 302 | } |
||
| 303 | if (null !== $object->getUrlRewriteMode()) { |
||
| 304 | $data->{'UrlRewriteMode'} = $object->getUrlRewriteMode(); |
||
| 305 | } |
||
| 306 | if (null !== $object->getUrlRewriteRules()) { |
||
| 307 | $values_5 = []; |
||
| 308 | foreach ($object->getUrlRewriteRules() as $value_5) { |
||
| 309 | $values_5[] = $this->normalizer->normalize($value_5, 'json', $context); |
||
| 310 | } |
||
| 311 | $data->{'UrlRewriteRules'} = $values_5; |
||
| 312 | } |
||
| 313 | |||
| 314 | return $data; |
||
| 315 | } |
||
| 317 |