alexkratky/simple-enum

Simple PHP Enum library.

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

This package is not auto-updated.

Last update: 2024-11-27 03:27:24 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