bayfrontmedia / array-schema
A simple library used to force a predefined "schema" for a given array.
v2.1.0
2024-12-04 22:28 UTC
Requires
- php: ^8.0
- bayfrontmedia/php-array-helpers: ^2.0
README
A simple library used to force a predefined "schema" for a given array.
License
This project is open source and available under the MIT License.
Author
Requirements
- PHP
^8.0
Installation
composer require bayfrontmedia/array-schema
Usage
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:
create
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)