| Conditions | 3 |
| Paths | 3 |
| Total Lines | 18 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 5 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 64 | 2 | public function get_amount() { |
|
| 65 | $amount = 0; |
||
| 66 | |||
| 67 | 2 | $use_bcmath = extension_loaded( 'bcmath' ); |
|
| 68 | |||
| 69 | 2 | foreach ( $this->items as $item ) { |
|
| 70 | if ( $use_bcmath ) { |
||
| 71 | 2 | // Use non-locale aware float value. |
|
| 72 | // @link http://php.net/sprintf. |
||
| 73 | $item_amount = sprintf( '%F', $item->get_amount() ); |
||
| 74 | |||
| 75 | 2 | $amount = bcadd( $amount, $item_amount, 8 ); |
|
| 76 | } else { |
||
| 77 | $amount += $item->get_amount(); |
||
| 78 | } |
||
| 79 | } |
||
| 80 | |||
| 81 | return new Money( $amount ); |
||
| 82 | } |
||
| 84 |