| 1 | <?php |
||
| 10 | class MoneyColumn extends AbstractColumn |
||
| 11 | { |
||
| 12 | public function buildCell(Cell $cell, array $options) |
||
| 13 | { |
||
| 14 | $value = $cell->value; |
||
| 15 | |||
| 16 | if (null === $value) { |
||
| 17 | return; |
||
| 18 | } |
||
| 19 | |||
| 20 | if (false === is_int($value)) { |
||
| 21 | throw new \InvalidArgumentException(sprintf( |
||
| 22 | 'Money column requires an integer value, got "%s"', |
||
| 23 | gettype($value) |
||
| 24 | )); |
||
| 25 | } |
||
| 26 | |||
| 27 | $cell->value = $cell->value / $options['divisor']; |
||
| 28 | $cell->value = number_format($cell->value, $options['scale']); |
||
| 29 | $cell->parameters['currency'] = $options['currency']; |
||
| 30 | } |
||
| 31 | |||
| 32 | public function configureOptions(OptionsResolver $resolver) |
||
| 38 | |||
| 39 | public function getParent() |
||
| 43 | } |
||
| 44 |