PluginProbe
MultiSafepay plugin for WooCommerce / trunk
MultiSafepay plugin for WooCommerce vtrunk
6.11.1 6.12.0 6.13.0 6.2.0 6.2.1 6.3.0 6.3.1 6.4.0 6.4.1 6.4.2 6.4.3 6.5.0 6.5.1 6.6.0 6.6.1 6.6.2 6.7.0 6.7.1 6.7.2 6.7.3 6.8.0 6.8.1 6.8.2 6.8.3 6.9.0 All 84 releases
multisafepay / src / Utils / MoneyUtil.php

MoneyUtil.php in MultiSafepay plugin for WooCommerce trunk, at src/Utils/MoneyUtil.php

30 lines 673 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php declare(strict_types=1);
2
3 namespace MultiSafepay\WooCommerce\Utils;
4
5 use MultiSafepay\ValueObject\Money;
6
7 /**
8 * Class MoneyUtil
9 */
10 class MoneyUtil {
11 public const DEFAULT_CURRENCY_CODE = 'EUR';
12
13 /**
14 * @param float $amount
15 * @param string $currency_code
16 * @return Money
17 */
18 public static function create_money( float $amount, string $currency_code = self::DEFAULT_CURRENCY_CODE ): Money {
19 return new Money( self::price_to_cents( $amount ), $currency_code );
20 }
21
22 /**
23 * @param float $price
24 * @return float
25 */
26 private static function price_to_cents( float $price ) {
27 return $price * 100;
28 }
29 }
30