aaronbullard / php-schema
v1.0.0
2018-11-11 23:19 UTC
Requires
- php: ^7.1
- justinrainbow/json-schema: ^5.2
Requires (Dev)
- mockery/mockery: ^1.1
- phpunit/phpunit: ^7.3
This package is auto-updated.
Last update: 2024-10-16 08:22:23 UTC
README
Self validating PHP objects from JSON Schema
Installation
Library
git clone https://github.com/aaronbullard/php-schema.git
Composer
composer require aaronbullard/php-schema
Testing
composer test
Usage
PhpSchema provides a quick solution to roll objects from JSON Schema.
Objects self validate during construction and when mutated.
In keeping with DDD principles, PhpSchema objects should always be in a valid state. Therefore all required properties must be passed through the constructor. Any optional properties can be passed after instantiation.
Validation is built off of JsonSchema\Validator from justinrainbow/json-schema
Examples
- PublicProperties Trait
- MethodAccess Trait
- Converting to Array, Json, or StdClass
- Integrating with non-PhpSchema classes
For more examples, see the tests: tests\ModelTest.php