src/Enum.php
final public function equals(Enum $b)
    {
        $aClass = get_class($this);
        $bClass = get_class($b);

        if ($aClass !== $bClass) {
            throw new InvalidArgumentException("Unexpected type {$bClass} is not of type {$aClass}.");
        }

        return $b->getName() === $this->getName();
    }
final public function equals(Enum $b)
    {
        $aClass = get_class($this);
        $bClass = get_class($b);

        if ($aClass !== $bClass) {
            throw new InvalidArgumentException("Unexpected type {$bClass} is not of type {$aClass}.");
        }

        return $b->getName() === $this->getName();
    }
final public function equals ( Enum $ b ) { $ aClass = get_class ( $ this ) ; $ bClass = get_class ( $ b ) ; if ( $ aClass !== $ bClass ) { throw new InvalidArgumentException ( "Unexpected type {$bClass} is not of type {$aClass}." ) ; } return $ b -> getName ( ) === $ this -> getName ( ) ; }
Only two Enums of the same type can be compared.
They are equal if their label is the same.

<br/>

For example:

<br/>

```
Fruit::APPLE()->equals(Fruit::BANANA()); // false
Fruit::APPLE()->equals(Fruit::APPLE()); // true
Fruit::APPLE()->equals(VEGETABLE::SPINACH()); // exception
```

@param Enum $b

@return bool
@throws InvalidArgumentException If $b is not of the same type as this Enum.
Only two Enums of the same type can be compared . They are equal if their label is the same .