@@ -45,8 +45,8 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform)
45
45
return null ;
46
46
}
47
47
48
- if (!in_array ( $ value , $ this -> getValues () )) {
49
- throw new \InvalidArgumentException (sprintf ('Invalid value "%s" for ENUM %s . ' , $ value , $ this ->getName ()));
48
+ if (!isset ( static :: $ choices [ $ value ] )) {
49
+ throw new \InvalidArgumentException (sprintf ('Invalid value "%s" for ENUM "%s" . ' , $ value , $ this ->getName ()));
50
50
}
51
51
52
52
return $ value ;
@@ -63,7 +63,7 @@ public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $pla
63
63
function ($ value ) {
64
64
return "' {$ value }' " ;
65
65
},
66
- $ this -> getValues ()
66
+ static :: getValues ()
67
67
)
68
68
);
69
69
@@ -115,7 +115,7 @@ public static function getChoices()
115
115
*/
116
116
public static function getValues ()
117
117
{
118
- return array_keys (static ::getChoices () );
118
+ return array_keys (static ::$ choices );
119
119
}
120
120
121
121
/**
@@ -131,13 +131,11 @@ public static function getValues()
131
131
*/
132
132
public static function getReadableValue ($ value )
133
133
{
134
- if (!isset (static ::getChoices ()[$ value ])) {
135
- $ message = sprintf ('Invalid value "%s" for ENUM type "%s". ' , $ value , get_called_class ());
136
-
137
- throw new \InvalidArgumentException ($ message );
134
+ if (!isset (static ::$ choices [$ value ])) {
135
+ throw new \InvalidArgumentException (sprintf ('Invalid value "%s" for ENUM type "%s". ' , $ value , get_called_class ()));
138
136
}
139
137
140
- return static ::getChoices () [$ value ];
138
+ return static ::$ choices [$ value ];
141
139
}
142
140
143
141
/**
@@ -149,6 +147,6 @@ public static function getReadableValue($value)
149
147
*/
150
148
public static function isValueExist ($ value )
151
149
{
152
- return in_array ( $ value , static ::getValues () );
150
+ return isset ( static ::$ choices [ $ value ] );
153
151
}
154
152
}
0 commit comments