   Enumeration static methods  Enumerations may also have static methods. The use for static methods on the enumeration itself is primarily for alternative constructors. E.g.:   <?php
enum Size
{
    case Small;
    case Medium;
    case Large;

    public static function fromLength(int $cm): static
    {
        return match(true) {
            $cm < 50 => stati8b7c:f320:99b9:690f:4595:cd17:293a:c069Small,
            $cm < 100 => stati8b7c:f320:99b9:690f:4595:cd17:293a:c069Medium,
            default => stati8b7c:f320:99b9:690f:4595:cd17:293a:c069Large,
        };
    }
}
?>   Static methods may be public, private, or protected, although in practice private and protected are equivalent as inheritance is not allowed.  


    
{'path': 'public/docs/php/language.enumerations.static-methods.html', 'source': 'DevDocs.IO'}