A simple library used to force a predefined "schema" for a given array.
This project is open source and available under the MIT License.
- PHP
^8.0
(Tested up to8.4
)
composer require bayfrontmedia/array-schema
The intended usage is for a custom schema to implement Bayfront\ArraySchema\SchemaInterface
.
The Bayfront\ArraySchema\InvalidSchemaException
is provided for any exceptions thrown from a SchemaInterface
to optionally extend, which can simplify the process of catching exceptions.
The SchemaInterface
contains only one static method:
Description:
Returns an array conforming to the desired schema.
Parameters:
$array
(array): Input array$config = []
(array): Optional configuration array which can be used to pass options necessary to build the desired schema.
Returns:
- (array)