alexkratky/simple-enum

This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

Simple PHP Enum library.

dev-master 2021-09-06 13:39 UTC

This package is not auto-updated.

Last update: 2021-10-19 12:38:58 UTC


README

Simple PHP Enum library.

Installation

composer require alexkratky/simple-enum

Usage

require 'vendor/autoload.php';

use AlexKratky\Enum\Enum;

class TestEnum extends Enum {
    public const CZ = 'Czech Republic';
    public const SK = 'Slovakia Republic';
}

$enum = new TestEnum('Czech Republic');

echo $enum->key() . ': ' . $enum->value() . "\n";

var_dump(TestEnum::toArray());

var_dump(TestEnum::toArrayWithKeys());

See /examples/ for more examples