From e46592a23e493d4a248246caccd1f4b59a88154e Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 13 Mar 2016 00:09:20 +0100 Subject: [PATCH] Implement random --- Datatypes/Enum.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Datatypes/Enum.php b/Datatypes/Enum.php index 7d33e7771..2df44d0f2 100644 --- a/Datatypes/Enum.php +++ b/Datatypes/Enum.php @@ -84,4 +84,19 @@ abstract class Enum return in_array($value, $values, true); } + /** + * Get random enum value. + * + * @return mixed + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public static function getRandom() + { + $constants = self::getConstants(); + + return $this->constants[mt_rand(0, count($constants))]; + } + }