myCRED_Point_Type
Description
The myCRED_Point_Type object holds the structure and formatting of a given point type. It is used to ensure values are formatted correctly and are valid. It is used for both calculations as well as displaying or rendering point values.
Available since version 1.7
Object properties
Property | Type | Description | |
---|---|---|---|
myCRED_Point_Type Object (
|
|||
public $cred_id |
string | The point type key. | |
public $singular |
string | The point types given name in singular form. | |
public $plural |
string | The point types given name in plural form. | |
public $prefix |
string | The set prefix for this point type (if used). | |
public $suffix |
string | The set suffix for this point type (if used). | |
public $format |
array | An associated array about the format set for this point type. this includes:
|
|
public $lowest_value |
int or float | This is the lowest point value that can be processed based on the format setup. | |
)
|
Object Methods
public function __construct( $point_type = MYCRED_DEFAULT_TYPE_KEY ) {
|
||||
Description: | Constructs the point type object based on a point type key. | |||
---|---|---|---|---|
Variable | Type | Required | Description | |
$point_type |
string | Yes | The point type key. | |
} |
public function get_lowest_value() {
|
||||
Description: | Returns the lowest amount this point type setup can handle. For point types that use integers, this will be 1 while if using two decimal places, it would be 0.01. Used to ensure myCRED does not attempt to handle partial points. | |||
---|---|---|---|---|
} |
public function number( $number = '' ) {
|
||||
Description: | Formats a given value based on the format setup used by this point type. A point type that uses decimals will be returned as a float else an integer. | |||
---|---|---|---|---|
Variable | Type | Required | Description | |
$number |
string | Yes | A value that is to be converted into an int or float based on the point type setup. | |
} |
public function format( $number = '' ) {
|
||||
Description: | Returns a given value in a string form with separators, prefix or suffix applied. This method should only be used to display values and not for calculations. | |||
---|---|---|---|---|
Variable | Type | Required | Description | |
$number |
string | Yes | The point value to format. | |
} |
Object Example
myCRED_Point_Type Object ( [cred_id] => mycred_deed [singular] => Deed [plural] => Deeds [prefix] => [suffix] => de. [format] => Array ( [type] => bigint [decimals] => 0 [separators] => Array ( [decimal] => . [thousand] => , ) ) [lowest_value] => 1 )