sbooker / litgroup-enumerable-normalizer
LitGroup Enumerable normalizer
Installs: 4 597
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^8.0
- litgroup/enumerable: ^0.8
- symfony/serializer: ^6.0|^7.0
Requires (Dev)
- phpunit/phpunit: ^10.5
README
The sbooker/litgroup-enumerable-normalizer package provides the ability to normalize/denormalize litgroup/enumerable with Symfony serializer.
Installation
The preferred method of installation is via Packagist and Composer. Run
the following command to install the package and add it as a requirement to
your project's composer.json
:
composer require sbooker/litgroup-enumerable-normalizer
Examples
// Declare Enum use LitGroup\Enumerable\Enumerable; final class ColorEnum extends Enumerable { /** * @return self */ public static function red() { return self::createEnum('red'); } /** * @return self */ public static function green() { return self::createEnum('green'); } /** * @return self */ public static function blue() { return self::createEnum('blue'); } } // Configure Symfony serializer $serializer = new Symfony\Component\Serializer\Serializer([ new \Sbooker\LitGroupEnumerable\Normalizer\EnumerableNormalizer(), ]); // Normalize enum $normalized = $serializer->normalize(ColorEnum::red()); // $normalized === 'red'
License
See LICENSE file.