hell-sh/enum

A simple, abstract class to improve your 'enums'.

v1.2.1 2021-02-06 02:18 UTC

This package is auto-updated.

Last update: 2024-11-06 10:20:24 UTC


README

A simple, abstract class to improve your 'enums'.

Usage

  1. composer require hell-sh/enum ^1.0
  2. Make your enum(s) extend hellsh\Enum:
    namespace MyNamespace;
    use hellsh\Enum;
    final class MyEnum extends Enum
    {
        const ONE = "Eins";
        const TWO = "Zwei";
    }
  3. Enjoy the added methods:
  • MyEnum::valueOf(string $name)
  • MyEnum::all(): array
  • MyEnum::nameOf($value): ?string
  • MyEnum::validateName(string $name): bool
  • MyEnum::validateValue($value): bool