From 5ed3990fa27c1965de669f377a4ff4685801c877 Mon Sep 17 00:00:00 2001 From: Christoph Bach Date: Wed, 27 Mar 2024 17:49:48 +0100 Subject: [PATCH] add some documentation --- README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/README.md b/README.md index 9fe6ac8..28f2bf6 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,32 @@ +### Usage + +```php +$path = __DIR__ . '/fixtures/ifdo-test-v2.0.0.json'; +$obj = Ifdo::fromFile($path); + +// print errors to console if document is no valid +$obj->setDebug(true); + +// check if document is valid +$obj->isValid(); + +// get list of errors if there are any +$obj->getErrors(); + +// get full json as array +$obj->getJsonData(); + +// shorthands to safely access info +$obj->getImageSetHeader(); +$obj->getImageSetItems(); + +// use strict mode trigger exceptions for invalid files +$obj = Ifdo::fromString('{"some": "json"}', true); + +// get json encoded string +$obj->toString(); +``` + ### Testing ```bash