| Conditions | 10 |
| Paths | 81 |
| Total Lines | 36 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 1 | Features | 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 |
||
| 90 | public function process(callable $callback = null) |
||
| 91 | { |
||
| 92 | if (!$this->writers) { |
||
|
|
|||
| 93 | throw new RuntimeException('No writers set'); |
||
| 94 | } |
||
| 95 | |||
| 96 | foreach ($this->writers as $writer) { |
||
| 97 | $writer->prepare(); |
||
| 98 | } |
||
| 99 | |||
| 100 | if ($this->sorterMap->hasSorter()) { |
||
| 101 | $values = $this->reader->all(); |
||
| 102 | $this->sorterMap->apply($values); |
||
| 103 | } else { |
||
| 104 | $values = $this->reader; |
||
| 105 | } |
||
| 106 | |||
| 107 | foreach ($values as $k => $row) { |
||
| 108 | foreach ($this->writers as $writer) { |
||
| 109 | $copyRow = $row; |
||
| 110 | |||
| 111 | if ($this->filterMap->apply($copyRow)) { |
||
| 112 | $this->conversionMap->apply($copyRow); |
||
| 113 | $writer->writeItem($copyRow); |
||
| 114 | } |
||
| 115 | } |
||
| 116 | |||
| 117 | if ($callback) { |
||
| 118 | if (isset($copyRow)) { |
||
| 119 | $callback($copyRow); |
||
| 120 | } |
||
| 121 | } |
||
| 122 | } |
||
| 123 | |||
| 124 | foreach ($this->writers as $writer) { |
||
| 125 | $writer->finish(); |
||
| 126 | } |
||
| 129 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.