aaronbullard/php-schema

v1.0.0 2018-11-11 23:19 UTC

This package is auto-updated.

Last update: 2024-11-16 08:25:33 UTC


README

Maintainability Test Coverage

Self validating PHP objects from JSON Schema

Installation

Library

git clone https://github.com/aaronbullard/php-schema.git

Composer

Install PHP 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

  1. PublicProperties Trait
  2. MethodAccess Trait
  3. Converting to Array, Json, or StdClass
  4. Integrating with non-PhpSchema classes

For more examples, see the tests: tests\ModelTest.php