function BaseConstraint::arrayToObjectRecursive
Recursively cast an associative array to an object
Parameters
array $array:
Return value
object
3 calls to BaseConstraint::arrayToObjectRecursive()
- SchemaConstraint::check in vendor/
justinrainbow/ json-schema/ src/ JsonSchema/ Constraints/ SchemaConstraint.php - invokes the validation of an element
- SchemaStorage::addSchema in vendor/
justinrainbow/ json-schema/ src/ JsonSchema/ SchemaStorage.php - Adds schema with given identifier
- Validator::validate in vendor/
justinrainbow/ json-schema/ src/ JsonSchema/ Validator.php - Validates the given data against the schema and returns an object containing the results Both the php object and the schema are supposed to be a result of a json_decode call. The validation works as defined by the schema proposal in…
File
-
vendor/
justinrainbow/ json-schema/ src/ JsonSchema/ Constraints/ BaseConstraint.php, line 135
Class
- BaseConstraint
- A more basic constraint definition - used for the public interface to avoid exposing library internals.
Namespace
JsonSchema\ConstraintsCode
public static function arrayToObjectRecursive($array) {
$json = json_encode($array);
if (json_last_error() !== \JSON_ERROR_NONE) {
$message = 'Unable to encode schema array as JSON';
if (function_exists('json_last_error_msg')) {
$message .= ': ' . json_last_error_msg();
}
throw new InvalidArgumentException($message);
}
return (object) json_decode($json);
}