| Conditions | 19 |
| Paths | 972 |
| Total Lines | 54 |
| Code Lines | 31 |
| 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 |
||
| 67 | public function init() |
||
| 68 | { |
||
| 69 | parent::init(); |
||
| 70 | |||
| 71 | if ($this->has('required-actions')) { |
||
|
|
|||
| 72 | $requiredActions = $this->__get('required-actions'); |
||
| 73 | if (!empty($requiredActions)) { |
||
| 74 | foreach ($requiredActions as $index => $action) { |
||
| 75 | $this->requiredActions[] = new ActionSpecification($action); |
||
| 76 | } |
||
| 77 | } |
||
| 78 | } |
||
| 79 | |||
| 80 | if ($this->has('optional-actions')) { |
||
| 81 | $optionalActions = $this->__get('optional-actions'); |
||
| 82 | if (!empty($optionalActions)) { |
||
| 83 | foreach ($optionalActions as $index => $action) { |
||
| 84 | $this->optionalActions[] = new ActionSpecification($action); |
||
| 85 | } |
||
| 86 | } |
||
| 87 | } |
||
| 88 | |||
| 89 | if ($this->has('required-events')) { |
||
| 90 | $requiredEvents = $this->__get('required-events'); |
||
| 91 | if (!empty($requiredEvents)) { |
||
| 92 | foreach ($requiredEvents as $index => $event) { |
||
| 93 | $this->requiredEvents[] = new EventSpecification($event); |
||
| 94 | } |
||
| 95 | } |
||
| 96 | } |
||
| 97 | |||
| 98 | if ($this->has('optional-events')) { |
||
| 99 | $optionalEvents = $this->__get('optional-events'); |
||
| 100 | if (!empty($optionalEvents)) { |
||
| 101 | foreach ($optionalEvents as $index => $event) { |
||
| 102 | $this->optionalEvents[] = new EventSpecification($event); |
||
| 103 | } |
||
| 104 | } |
||
| 105 | } |
||
| 106 | |||
| 107 | if ($this->has('required-properties')) { |
||
| 108 | $requiredProperties = $this->__get('required-properties'); |
||
| 109 | if (!empty($requiredProperties)) { |
||
| 110 | foreach ($requiredProperties as $index => $property) { |
||
| 111 | $this->requiredProperties[] = new PropertySpecification($property); |
||
| 112 | } |
||
| 113 | } |
||
| 114 | } |
||
| 115 | |||
| 116 | if ($this->has('optional-properties')) { |
||
| 117 | $optionalProperties = $this->__get('optional-properties'); |
||
| 118 | if (!empty($optionalProperties)) { |
||
| 119 | foreach ($optionalProperties as $index => $property) { |
||
| 120 | $this->optionalProperties[] = new PropertySpecification($property); |
||
| 121 | } |
||
| 174 |