Skip to content

Releases: rexlabsio/enum-php

2.4.0 - PHP 8.3 and 8.4 compatibility release

07 Jan 23:23
b4d4be2

Choose a tag to compare

PHP compatibility release.

Now supports and has been tested with PHP 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4 (8.3 and 8.4 added).

2.3.0 - PHP 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2

20 Jul 01:14
1cd66f3

Choose a tag to compare

PHP compatibility release.

Now supports and has been tested with PHP 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2

2.2.0 - Feature: Add expressive check methods

16 Mar 14:15

Choose a tag to compare

  • Adds isNot, isAnyOf, isNoneOf expressive methods: See #12 for more context

2.1.0 - Feature: get all instances

21 Jul 01:47
9bdc8eb

Choose a tag to compare

Added

  • A static helper method to get all instances in an enum MyEnum::instances()

2.0.0 - New API (BC)

23 Sep 22:37
9f1ffa0

Choose a tag to compare

2.0.0

This release is a significant overhaul of the existing API, and therefore introduces breaking changes.
See the list of updates below, and consult the README for examples and details of the new API.

  • Add Enum::instanceFromKey($key)
  • Breaking Change $instance->identifier to $instance->name()
  • Breaking Change Enum::identifiers() to Enum::names()
  • Breaking Change Enum::getKeyForIdentfier() to Enum::keyForName()
  • Breaking Change Enum::valueFor() to Enum::valueForKey()
  • Add Enum::nameForKey() to get the constant name for a given key
  • Breaking Change Enum::exists() to Enum::isValidKey()
  • Breaking Change Enum::checkExists() to Enum::requireValidKey()
  • Fix $instance->key() to handle non-string keys
  • Fix $instance->is() to handle non-string keys
  • Fix late-static binding in some methods which referred to self::
  • Add Enum::instanceFromName($name) to get an instance via name (alternative to Enum::NAME())
  • Change implementation of Enum::instanceFromKey($key) to use array_search
  • Breaking Change: the default provided static map() method will return an array of constant keys mapped to null.
    Previously it returned an empty array [] when not overridden. In practice, this may not effect userland code.
  • Breaking Change: you can no longer provide a non-keyed array in an map() method implemented
    in your sub-class. This method should be used to map keys to values (if necessary). A default map() method is provided
    which maps keys to null values.
  • Breaking Change Enum::fromValue($val) has been renamed to Enum::keyForValue()
  • Breaking Change: removed Enum::flip()
  • Breaking Change Enum::constantMap() to Enum::namesAndKeys()
  • Updated README to reflect API changes
  • Add Enum::valueForName($name) for completeness

1.1.0 - Constants By Value

29 Aug 23:57
ad27a93

Choose a tag to compare

Adds new functionality.

1.0.0 - Initial release

06 Mar 08:39

Choose a tag to compare

Initial release of enum library.
See README.md for details about this package.