Conditions | 3 |
Paths | 3 |
Total Lines | 15 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 0 |
1 | <?php |
||
37 | public function format($value) { |
||
38 | if(!($value instanceof DataValue)) { |
||
39 | throw new InvalidArgumentException('$value should be a DataValue'); |
||
40 | } |
||
41 | |||
42 | $type = $value->getType(); |
||
43 | |||
44 | if(!array_key_exists($type, $this->formatters)) { |
||
45 | throw new FormattingException( |
||
46 | $type . ' is not one of the type supported by the value formatter (' . implode(', ', array_keys($this->formatters)) . ')' |
||
47 | ); |
||
48 | } |
||
49 | |||
50 | return $this->formatters[$type]->format($value); |
||
51 | } |
||
52 | } |
||
53 |