| Conditions | 4 |
| Paths | 4 |
| Total Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 0 | ||
| 1 | <?php |
||
| 33 | public function populate($rows) |
||
| 34 | { |
||
| 35 | $indexBy = $this->indexBy; |
||
| 36 | |||
| 37 | if ($indexBy === null) { |
||
| 38 | return $this->createObjects($rows); |
||
| 39 | } |
||
| 40 | $result = []; |
||
| 41 | foreach ($rows as $row) { |
||
| 42 | if (is_string($indexBy)) { |
||
| 43 | $key = $row[$indexBy]; |
||
| 44 | } else { |
||
| 45 | $key = call_user_func($indexBy, $row); |
||
| 46 | } |
||
| 47 | $result[$key] = $this->createObject($row); |
||
| 48 | } |
||
| 49 | return $result; |
||
| 50 | } |
||
| 51 | |||
| 68 |