| Conditions | 23 |
| Paths | 12 |
| Total Lines | 49 |
| Code Lines | 35 |
| Lines | 8 |
| Ratio | 16.33 % |
| 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 |
||
| 310 | public function isGInlineExpressionsValid(&$msg = null) |
||
| 311 | { |
||
| 312 | if (null != $this->string && !is_string($this->string)) { |
||
| 313 | $msg = "String must be a string"; |
||
| 314 | return false; |
||
| 315 | } |
||
| 316 | if (null != $this->binary && !$this->hexBinary($this->binary)) { |
||
| 317 | $msg = "Binary must be hexadecimal"; |
||
| 318 | return false; |
||
| 319 | } |
||
| 320 | if (null != $this->int && $this->int !== intval($this->int)) { |
||
| 321 | $msg = "Integer must be integral"; |
||
| 322 | return false; |
||
| 323 | } |
||
| 324 | if (null != $this->float && $this->float !== floatval($this->float)) { |
||
| 325 | $msg = "Float must be floating-point"; |
||
| 326 | return false; |
||
| 327 | } |
||
| 328 | if (null != $this->guid && !$this->isTGuidLiteralValid($this->guid)) { |
||
| 329 | $msg = "Guid must be valid GUID"; |
||
| 330 | return false; |
||
| 331 | } |
||
| 332 | if (null != $this->bool && $this->bool !== boolval($this->bool)) { |
||
| 333 | $msg = "Bool must be boolean"; |
||
| 334 | return false; |
||
| 335 | } |
||
| 336 | if (null != $this->decimal && $this->decimal !== floatval($this->decimal)) { |
||
| 337 | $msg = "Decimal must be decimal"; |
||
| 338 | return false; |
||
| 339 | } |
||
| 340 | View Code Duplication | if (null != $this->enum && !$this->isTQualifiedNameValid($this->enum)) { |
|
|
|
|||
| 341 | $msg = "Enum must be a valid TQualifiedName"; |
||
| 342 | return false; |
||
| 343 | } |
||
| 344 | View Code Duplication | if (null != $this->path && !$this->isTQualifiedNameValid($this->path)) { |
|
| 345 | $msg = "Path must be a valid TQualifiedName"; |
||
| 346 | return false; |
||
| 347 | } |
||
| 348 | if (null != $this->dateTime && $this->dateTime !== $this->dateTime($this->dateTime)) { |
||
| 349 | $msg = "DateTime must be a valid date/time"; |
||
| 350 | return false; |
||
| 351 | } |
||
| 352 | if (null != $this->dateTimeOffset && $this->dateTimeOffset !== $this->dateTime($this->dateTimeOffset)) { |
||
| 353 | $msg = "DateTimeOffset must be a valid date/time"; |
||
| 354 | return false; |
||
| 355 | } |
||
| 356 | |||
| 357 | return true; |
||
| 358 | } |
||
| 359 | } |
||
| 360 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.