Skip to content

Commit c312f73

Browse files
committed
Oops, added missing parseValue for EnumType
1 parent 83e3365 commit c312f73

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/Type/Definition/EnumType.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,30 @@ public function getValues()
5353
return $this->_values;
5454
}
5555

56+
/**
57+
* @param $value
58+
* @return null
59+
*/
5660
public function serialize($value)
5761
{
58-
$enumValue = $this->_getValueLookup()->offsetGet($value);
59-
return $enumValue ? $enumValue->name : null;
62+
$lookup = $this->_getValueLookup();
63+
return isset($lookup[$value]) ? $lookup[$value]->name : null;
6064
}
6165

66+
/**
67+
* @param $value
68+
* @return null
69+
*/
70+
public function parseValue($value)
71+
{
72+
$lookup = $this->_getNameLookup();
73+
return isset($lookup[$value]) ? $lookup[$value]->value : null;
74+
}
75+
76+
/**
77+
* @param $value
78+
* @return null
79+
*/
6280
public function parseLiteral($value)
6381
{
6482
if ($value instanceof EnumValue) {

0 commit comments

Comments
 (0)