| Conditions | 6 |
| Paths | 5 |
| Total Lines | 22 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 33 | public function format($value) |
||
| 34 | { |
||
| 35 | if (empty($value)) { |
||
| 36 | return $value; |
||
| 37 | } |
||
| 38 | |||
| 39 | if (!is_array($value) && !$value instanceof \Iterator) { |
||
| 40 | throw new \InvalidArgumentException("Collection decorator require value to be an array or implement \\Iterator"); |
||
| 41 | } |
||
| 42 | |||
| 43 | $formatted = array(); |
||
| 44 | foreach ($value as $key => $val) { |
||
| 45 | $formattedValue = $val; |
||
| 46 | foreach ($this->formatters as $formatter) { |
||
| 47 | $formattedValue = $formatter->format($formattedValue); |
||
| 48 | } |
||
| 49 | |||
| 50 | $formatted[$key] = $formattedValue; |
||
| 51 | } |
||
| 52 | |||
| 53 | return $formatted; |
||
| 54 | } |
||
| 55 | } |
||
| 56 |