jojo1981 / decoder-aggregate
Decoder aggregate library
Installs: 6 403
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^7.4|^8.0
- ext-json: *
- symfony/yaml: ^4.0|^5.2
Requires (Dev)
- dg/bypass-finals: ^1.3
- php-coveralls/php-coveralls: ^2.2
- phpspec/prophecy-phpunit: ^2.0
- phpunit/phpunit: ^9.5
- roave/security-advisories: dev-latest
This package is auto-updated.
Last update: 2024-11-06 23:37:20 UTC
README
Author: Joost Nijhuis <jnijhuis81@gmail.com>
This library will provide a decoder/encoder provider including some default encoders/decoders for json
and yaml
.
Installation
Library
git clone https://github.com/jojo1981/decoder-aggregate.git
Composer
composer require jojo1981/decoder-aggregate
Basic usage
<?php use Jojo1981\DecoderAggregate\Factory\EncoderDecoderProviderFactory; require 'vendor/autoload.php'; $encoderDecoderProviderFactory = new EncoderDecoderProviderFactory(); $encoderDecoderProviderFactory->addDefaultEncoders(); $encoderDecoderProviderFactory->addDefaultENcoders(); $encoderDecoderProvider = $encoderDecoderProviderFactory->getEncoderDecoderProvider(); $jsonResult = $encoderDecoderProvider->getDecoder('json')->decode(<<<JSON { "glossary": { "title": "example glossary", "GlossDiv": { "title": "S", "GlossList": { "GlossEntry": { "ID": "SGML", "SortAs": "SGML", "GlossTerm": "Standard Generalized Markup Language", "Acronym": "SGML", "Abbrev": "ISO 8879:1986", "GlossDef": { "para": "A meta-markup language, used to create markup languages such as DocBook.", "GlossSeeAlso": [ "GML", "XML" ] }, "GlossSee": "markup" } } } } } JSON ); $yamlResult = $encoderDecoderProvider->getDecoder('yaml')->decode(<<<YAML glossary: title: example glossary GlossDiv: title: S GlossList: GlossEntry: ID: SGML SortAs: SGML GlossTerm: Standard Generalized Markup Language Acronym: SGML Abbrev: ISO 8879:1986 GlossDef: para: A meta-markup language, used to create markup languages such as DocBook. GlossSeeAlso: - GML - XML GlossSee: markup YAML );