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