protected function pr_sanitize($id, $type, $type_sub = NULL) {
if (!is_string($id) && mb_strlen($id) > 0) {
$error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'id', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_value(NULL, 'c_base_return_null', $error);
+ return c_base_return_error::s_null($error);
}
if (!is_int($type)) {
$error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_value(NULL, 'c_base_return_null', $error);
+ return c_base_return_error::s_null($error);
}
if (!is_array($_POST) || !array_key_exists($id, $_POST)) {
}
/**
+ * Creates a return NULL with the error value populated.
+ *
+ * @param c_base_error|array|null $error
+ * (optional) a custom error setting.
+ * Can be an array of c_base_error for returning multiple errors.
+ * When NULL, no errors are defined.
+ *
+ * @return c_base_return_false
+ * A c_base_return_null object with the error value populated.
+ */
+ public static function s_null($error = NULL) {
+ $object_return = new c_base_return_null();
+
+ if (is_null($error)) {
+ $object_return->set_error(null);
+ }
+ elseif (is_array($error)) {
+ foreach ($error as $delta => $value) {
+ $object_return->set_error($error, $delta);
+ }
+ unset($delta);
+ unset($value);
+ }
+ else {
+ $object_return->set_error($error);
+ }
+
+ return $object_return;
+ }
+
+ /**
* Creates a return boolean TRUE with the error value populated.
*
* This will assign a value to the class.