szurubooru/src/Enum.php

18 lines
366 B
PHP
Raw Normal View History

2013-10-07 23:17:33 +02:00
<?php
class Enum
{
public static function toString($constant)
{
$cls = new ReflectionClass(get_called_class());
$constants = $cls->getConstants();
return array_search($constant, $constants);
}
2013-10-08 22:59:32 +02:00
public static function getAll()
{
$cls = new ReflectionClass(get_called_class());
$constants = $cls->getConstants();
return array_values($constants);
}
2013-10-07 23:17:33 +02:00
}