Skip to content

Releases: myclabs/php-enum

1.5.2

28 Jun 16:25
Compare
Choose a tag to compare

Remove unneeded file permissions.

1.5.1

26 Mar 10:26
Compare
Choose a tag to compare

Bugfix in the equals() method

Issue: #47
Pull request: #48
Contributed by @peter-gribanov

Example:

class CommandAction extends Enum
{
    const EDIT = 'edit';
}

class AccessRule extends Enum
{
    const EDIT = 'edit';
}

Expected

CommandAction::EDIT()->equals(AccessRule::EDIT()); // false

Actual

CommandAction::EDIT()->equals(AccessRule::EDIT()); // true

1.5.0

09 Oct 21:45
Compare
Choose a tag to compare

#4 #39 #40: new equals() method to compare enums

$enum = MyEnum::FOO();

if ($enum->equals(MyEnum::BAR())) {
    ...
}

It behaves the same as ==:

if ($enum == MyEnum::BAR()) {
    ...
}

It was added because it carries a bit more sense than == which, because it is a loose comparison, is often source of confusion (comparing objects with == is often a no-go for good reasons).

1.4.2

01 Aug 15:49
Compare
Choose a tag to compare
  • #36, #37 Small phpdoc improvement for better autocompletion in IDEs

1.4.1

22 Jul 16:15
Compare
Choose a tag to compare

#21 Allow to extend the class to fetch values from somewhere else than the class constants (e.g. a database, file, …)

1.4.0

19 May 05:29
Compare
Choose a tag to compare

New static method values(): returns instances of the Enum class of all Enum constants (constant name in key, Enum instance in value).

MyEnum::values()

1.3.2

15 Feb 21:40
Compare
Choose a tag to compare
  • Fixed #9 Ability to create invalid enum
  • Fixed #13 search() is not type safe

1.3.1

03 Feb 20:44
Compare
Choose a tag to compare

Small performance enhancement.

1.3.0

30 Jan 22:08
Compare
Choose a tag to compare

A bunch of new methods were added in #5:

  • $value->getKey() Returns the key of the current value on Enum
  • Enum::keys() Returns the names (keys) of all constants in the Enum class
  • Enum::isValid() Check if tested value is valid on enum set
  • Enum::isValidKey() Check if tested key is valid on enum set
  • Enum::search() Return key for searched value

The library is now PSR-4 compliant.

1.2.1

11 Nov 18:31
Compare
Choose a tag to compare
  • #2 [Performances] Enum::toArray() now caches the results per class to improve performances (thanks to @garoevans)