https://github.com/bayfrontmedia/array-schema
A simple library used to force a predefined "schema" for a given array.
https://github.com/bayfrontmedia/array-schema
Last synced: 2 months ago
JSON representation
A simple library used to force a predefined "schema" for a given array.
- Host: GitHub
- URL: https://github.com/bayfrontmedia/array-schema
- Owner: bayfrontmedia
- License: mit
- Created: 2020-11-06T18:58:51.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-12-23T21:36:13.000Z (7 months ago)
- Last Synced: 2025-05-12T14:15:27.629Z (2 months ago)
- Language: PHP
- Size: 33.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
## Array Schema
A simple library used to force a predefined "schema" for a given array.
- [License](#license)
- [Author](#author)
- [Requirements](#requirements)
- [Installation](#installation)
- [Usage](#usage)## License
This project is open source and available under the [MIT License](LICENSE).
## Author
- [Bayfront Media homepage](https://www.bayfrontmedia.com?utm_source=github&utm_medium=direct)
- [Bayfront Media GitHub](https://github.com/bayfrontmedia)## Requirements
* PHP `^8.0` (Tested up to `8.4`)
## Installation
```shell
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](#create)
### 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)