From c312f73df32a00d709a025cb509a3f7e6cc4ddc3 Mon Sep 17 00:00:00 2001 From: vladar Date: Sun, 6 Sep 2015 15:49:23 +0600 Subject: [PATCH] Oops, added missing parseValue for EnumType --- src/Type/Definition/EnumType.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Type/Definition/EnumType.php b/src/Type/Definition/EnumType.php index 8a7f37e..3767562 100644 --- a/src/Type/Definition/EnumType.php +++ b/src/Type/Definition/EnumType.php @@ -53,12 +53,30 @@ class EnumType extends Type implements InputType, OutputType return $this->_values; } + /** + * @param $value + * @return null + */ public function serialize($value) { - $enumValue = $this->_getValueLookup()->offsetGet($value); - return $enumValue ? $enumValue->name : null; + $lookup = $this->_getValueLookup(); + return isset($lookup[$value]) ? $lookup[$value]->name : null; } + /** + * @param $value + * @return null + */ + public function parseValue($value) + { + $lookup = $this->_getNameLookup(); + return isset($lookup[$value]) ? $lookup[$value]->value : null; + } + + /** + * @param $value + * @return null + */ public function parseLiteral($value) { if ($value instanceof EnumValue) {