<?php enum MethodConstraint :string { case A = "a"; case B = "b"; case C = "c"; public function getMethod(): string { return $this->value; } public function getMethodSentence($value): string { return match ($value) { MethodConstraint::A => "This is an A char", MethodConstraint::B => "This is a B char", MethodConstraint::C => "This is a C char" }; } public function getCharAndSentence(): string { return $this->getMethod()." ".$this->getMethodSentence($this); } } $aChar = MethodConstraint::A; echo $aChar->getMethod().PHP_EOL; echo $aChar->getMethodSentence(MethodConstraint::B).PHP_EOL; echo $aChar->getCharAndSentence();
You have javascript disabled. You will not be able to edit any code.