* @license http://www.apache.org/licenses/LICENSE-2.0 * @link http://phpsx.org */ class TestSchema extends SchemaAbstract { public function build(): void { $location = $this->newStruct('Location'); $location->setDescription('Location of the person'); $location->addNumber('lat'); $location->addNumber('long'); $location->setRequired(['lat', 'long']); $location->setAttribute(TypeAbstract::ATTR_CLASS, Popo\Location::class); $web = $this->newStruct('Web'); $web->setDescription('An application'); $web->addString('name'); $web->addString('url'); $web->setRequired(['name', 'url']); $web->setAttribute(TypeAbstract::ATTR_CLASS, Popo\Web::class); $author = $this->newStruct('Author'); $author->setDescription('An simple author element with some description'); $author->addString('title') ->setPattern('[A-z]{3,16}'); $author->addString('email') ->setDescription('We will send no spam to this address') ->setNullable(true); $author->addArray('categories', TypeFactory::getString()) ->setMaxItems(8); $author->addArray('locations', TypeFactory::getReference('Location')) ->setDescription('Array of locations'); $author->addReference('origin', 'Location'); $author->setRequired(['title']); $author->setAttribute(TypeAbstract::ATTR_CLASS, Popo\Author::class); $meta = $this->newMap('Meta'); $meta->setAdditionalProperties(TypeFactory::getString()); $meta->setMinProperties(1); $meta->setMaxProperties(6); $meta->setAttribute(TypeAbstract::ATTR_CLASS, Popo\Meta::class); $news = $this->newStruct('News'); $news->setDescription('An general news entry'); $news->addReference('config', 'Meta'); $news->addArray('tags', TypeFactory::getString()) ->setMinItems(1) ->setMaxItems(6); $news->addArray('receiver', TypeFactory::getReference('Author')) ->setMinItems(1); $news->addArray('resources', TypeFactory::getUnion([ TypeFactory::getReference('Location'), TypeFactory::getReference('Web') ])); $news->addBinary('profileImage'); $news->addBoolean('read'); $news->addUnion('source', [ TypeFactory::getReference('Author'), TypeFactory::getReference('Web') ]); $news->addReference('author', 'Author'); $news->addReference('meta', 'Meta'); $news->addDate('sendDate'); $news->addDateTime('readDate'); $news->addDuration('expires'); $news->addNumber('price') ->setMinimum(1) ->setMaximum(100); $news->addInteger('rating') ->setMinimum(1) ->setMaximum(5); $news->addString('content') ->setDescription('Contains the main content of the news entry') ->setMinLength(3) ->setMaxLength(512); $news->addString('question') ->setEnum(['foo', 'bar']); $news->addString('version') ->setConst('http://foo.bar'); $news->addTime('coffeeTime'); $news->addUri('profileUri'); $news->addString('g-recaptcha-response'); $news->setRequired(['receiver', 'price', 'content']); $news->setAttribute(TypeAbstract::ATTR_CLASS, Popo\News::class); $news->setAttribute(TypeAbstract::ATTR_MAPPING, ['g-recaptcha-response' => 'captcha']); } } __halt_compiler();----SIGNATURE:----MA4hcRPPgOV73IzjtySKqaZPuWPdP9K4Ppz6q42eLCp+XefrR30qnp6yG2NEulmDMBe//cdukIkJ5QxLDVL0v96TUUxqN3PsNBNfAkVcAEOo0+BvRjp0d1gcYRO1ylXkE67ae42qC5XiJh0eUmHwwhW7s+KKznpLUvxFm7UUC3zXQwBget07mNBPOjtjL8krbHedSrTnZVIGcOFGtKnT8VK3yMFKxbnR4wq4LsF31jEixtN8uk0+NToTdhGSk13iqviFD5dLT3/YifTuKBf1bb14gS1IP+BUqwBbvwCOzEkzIZr3CipiNr4uyEcLTWH6lQyCDRzrM2/ARI//w0oETrB/uYQ8bEGd/ezQWI1rD9rgPROxqRW5UJQoDn64Y2DDUb0GWE2oKVsg8Urnz/6NAj23h28qoHr3OKkmoxoFmP9QqLS0mw6ijRf3j7879/qqpttUHRjuliuP9LLNCMJMxWTTBdTus3ulD/GdFQL1FaNZThNlzKiAYcX5EYxfgRbEvzurYmIfOQuipbbrk3MWiDKcI48Xxtl+DEhFoWbbX6Y92Rpl30b5UMLITWQsuw4AmI6Mplv1eBgg0KgzjUXqtQo5WDH44wFjxOKIUgtZ8x4rgXfVa7hugH6mGZ4KjV8HgN8/9T5DWKiSI+XRnobm9r3RUGvGhBoNnVtWohqiwAE=----ATTACHMENT:----OTcwMTYxMzk5MzM1ODcyMyAxMzk5NDA3MTQ0MDMxODQ5IDkxMzQxNDkzMjU3NjU2NTY=