| Conditions | 11 |
| Paths | 144 |
| Total Lines | 41 |
| 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 |
||
| 50 | public function process($name = 'default', $values = null, $print = true, $advance = true, $delimiter = ',', $assign = null, $reset = false) |
||
| 51 | { |
||
| 52 | if ($values !== null) { |
||
| 53 | if (is_string($values)) { |
||
| 54 | $values = explode($delimiter, $values); |
||
| 55 | } |
||
| 56 | |||
| 57 | if (!isset($this->cycles[$name]) || $this->cycles[$name]['values'] !== $values) { |
||
| 58 | $this->cycles[$name]['index'] = 0; |
||
| 59 | } |
||
| 60 | |||
| 61 | $this->cycles[$name]['values'] = array_values($values); |
||
| 62 | } elseif (isset($this->cycles[$name])) { |
||
| 63 | $values = $this->cycles[$name]['values']; |
||
| 64 | } |
||
| 65 | |||
| 66 | if ($reset) { |
||
| 67 | $this->cycles[$name]['index'] = 0; |
||
| 68 | } |
||
| 69 | |||
| 70 | if ($print) { |
||
| 71 | $out = $values[$this->cycles[$name]['index']]; |
||
| 72 | } else { |
||
| 73 | $out = null; |
||
| 74 | } |
||
| 75 | |||
| 76 | if ($advance) { |
||
| 77 | if ($this->cycles[$name]['index'] >= count($values) - 1) { |
||
| 78 | $this->cycles[$name]['index'] = 0; |
||
| 79 | } else { |
||
| 80 | ++ $this->cycles[$name]['index']; |
||
| 81 | } |
||
| 82 | } |
||
| 83 | |||
| 84 | if ($assign === null) { |
||
| 85 | return $out; |
||
| 86 | } |
||
| 87 | $this->core->assignInScope($out, $assign); |
||
| 88 | |||
| 89 | return null; |
||
| 90 | } |
||
| 91 | } |
||
| 92 |