Conditions | 11 |
Paths | 9 |
Total Lines | 48 |
Code Lines | 28 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
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 |
||
128 | public function process() |
||
129 | { |
||
130 | $remainingChildren = $this->remainingChildren; |
||
131 | |||
132 | if (!count($remainingChildren)) { |
||
133 | $this->isComplete = true; |
||
134 | return; |
||
135 | } |
||
136 | |||
137 | $this->currentStep++; |
||
138 | |||
139 | // lets process our first item |
||
140 | $pair = array_shift($remainingChildren); |
||
141 | $sourceObject = ExternalContent::getDataObjectFor($pair->sourceID); |
||
142 | if (!$sourceObject) { |
||
143 | $this->addMessage("Missing source object for " . $pair->sourceID, 'WARNING'); |
||
144 | $this->remainingChildren = $remainingChildren; |
||
145 | return; |
||
146 | } |
||
147 | |||
148 | $targetObject = DataObject::get_by_id($pair->targetType, $pair->targetID); |
||
149 | if (!$targetObject) { |
||
150 | $this->addMessage("Missing target object for $pair->targetType $pair->sourceID", 'WARNING'); |
||
151 | $this->remainingChildren = $remainingChildren; |
||
152 | return; |
||
153 | } |
||
154 | |||
155 | // lets do a single import first, then check the children and append them |
||
156 | $pageType = $this->getExternalType($sourceObject); |
||
157 | if (isset($this->contentTransforms[$pageType])) { |
||
158 | $transformer = $this->contentTransforms[$pageType]; |
||
159 | |||
160 | $result = $transformer->transform($sourceObject, $targetObject, $this->duplicateStrategy); |
||
161 | |||
162 | // if there's more, then transform them |
||
163 | if ($this->includeChildren && $result && $result->children && count($result->children)) { |
||
164 | foreach ($result->children as $child) { |
||
165 | $remainingChildren[] = new EC_SourceTarget($child->ID, $result->page->ID, $result->page->ClassName); |
||
166 | $this->totalSteps++; |
||
167 | } |
||
168 | } |
||
169 | } |
||
170 | |||
171 | $this->remainingChildren = $remainingChildren; |
||
172 | |||
173 | if (!count($remainingChildren)) { |
||
174 | $this->isComplete = true; |
||
175 | return; |
||
176 | } |
||
206 |