Automattic\WooCommerce\Admin\API\Reports
DataStore::cast_numbers()
Casts strings returned from the database to appropriate data types for output.
Method of the class: DataStore{}
Hooks from the method
Return
Array|WP_Error
.
Usage
// protected - for code of main (parent) or child class $result = $this->cast_numbers( $array );
- $array(array) (required)
- Associative array of values extracted from the database.
DataStore::cast_numbers() DataStore::cast numbers code WC 9.5.1
protected function cast_numbers( $array ) { $retyped_array = array(); $column_types = apply_filters( 'woocommerce_rest_reports_column_types', $this->column_types, $array ); foreach ( $array as $column_name => $value ) { if ( is_array( $value ) ) { $value = $this->cast_numbers( $value ); } if ( isset( $column_types[ $column_name ] ) ) { $retyped_array[ $column_name ] = $column_types[ $column_name ]( $value ); } else { $retyped_array[ $column_name ] = $value; } } return $retyped_array; }