public static function forValue($value)
    {
        $enumClass = new \ReflectionClass(get_called_class());
        foreach ($enumClass->getStaticProperties() as $instance) {
            if ($instance->value() === $value) {
                return $instance;
            }
        }

        throw new \InvalidArgumentException(
                'Enum ' . $enumClass->getName() . ' for value ' . $value
                . ' does not exist.'
        );
    }