forked from gocodebox/lifterlms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass.llms.number.php
55 lines (43 loc) · 998 Bytes
/
class.llms.number.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; }
/**
* Number Class
*
* Manages formatting numbers for I/O and display
*/
class LLMS_Number {
/**
* Constructor
*/
public function __construct() {
}
/**
* Format number to money with decimals
*
* @param [int] $number
* @return [string]
*/
public static function format_money( $number ) {
return get_lifterlms_currency_symbol() . number_format( (int) $number, 2, '.', ',' );
}
/**
* Format number to money with no decimals
*
* @param [int] $number
* @return [string]
*/
public static function format_money_no_decimal( $number ) {
return get_lifterlms_currency_symbol() . number_format( $number );
}
/**
* Converts and rounds a decimal to a whole number
*
* @param [decimal] $decimal [percentage]
* @return [int] [whole number representation of decimal value]
*/
public static function whole_number( $decimal ) {
return round( $decimal * 100 );
}
}
return new LLMS_Number();