File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -278,6 +278,29 @@ public static function search($value)
278278 return \array_search ($ value , static ::toArray (), true );
279279 }
280280
281+ /**
282+ * Constant value desc array
283+ * @return array
284+ */
285+ public static function valueDesc ()
286+ {
287+ return [];
288+ }
289+
290+ /**
291+ * Get constant value desc
292+ * @param $value
293+ * @return mixed
294+ */
295+ public static function getDesc ($ value )
296+ {
297+ if (!isset (static ::valueDesc ()[$ value ])) {
298+ throw new \UnexpectedValueException ("Value ' $ value' is not part of the enum " . static ::class);
299+ }
300+
301+ return static ::valueDesc ()[$ value ];
302+ }
303+
281304 /**
282305 * Returns a value when called statically like so: MyEnum::SOME_VALUE() given SOME_VALUE is a class constant
283306 *
You can’t perform that action at this time.
0 commit comments