/** * Get the sum total of a given array's values. * @param array with values * @return int || float */ public static function total($array = false, $decimals = 2) { if ($array && Validate::isArray($array)) { return self::round(array_sum($array), $decimals); } return false; }
/** * Sanitize input. * @param array || string * @return array || string */ public function sanitize($input = false) { if ($input) { if (Validate::isArray($input)) { return filter_var_array($input, FILTER_SANITIZE_STRING); } if (Validate::isString($input)) { return filter_var($input, FILTER_SANITIZE_STRING); } } return false; }
/** * Format array into object. * @param array of data to be formatted * @return object */ public static function arrayToObject($array = false) { if ($array && Validate::isArray($array)) { $object = new \stdClass(); foreach ($array as $key => $value) { $object->{$key} = $value; } return $object; } return false; }