Skip to content

Instantly share code, notes, and snippets.

@praisedare
Created June 23, 2023 15:12
Show Gist options
  • Save praisedare/df931e62d2c6e4e635e26eb31a7e8eb3 to your computer and use it in GitHub Desktop.
Save praisedare/df931e62d2c6e4e635e26eb31a7e8eb3 to your computer and use it in GitHub Desktop.
<?php
/**
* Adds a static `values` method that returns an array
* containing the values of a backed enum
*/
trait ListableEnumValues
{
static function values(): array
{
return collect(self::cases())->pluck('value')->all();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment