data type consisting of a set of named values called elements … of the type. The enumerator names are usually identifiers that behave as constants in the language. https:/ /en.wikipedia.org/wiki/Enumerated_type
... protected $value; // ... public function value() { return $this->value; } public function equals(Color $color) { // or any other business condition return $this->value === $color->value(); } }
... protected $value; // ... public static function fromHex(string $hex) { // do something with $hex and get $color return new self($color); } public function format() { return 'My special color format'; } }