@@ -97,8 +97,7 @@ public function search($value, bool $strict = false): ?Enum
97
97
{
98
98
$ ord = \array_search ($ value , $ this ->map , $ strict );
99
99
if ($ ord !== false ) {
100
- $ enumeration = $ this ->enumeration ;
101
- return $ enumeration ::byOrdinal ($ ord );
100
+ return ($ this ->enumeration )::byOrdinal ($ ord );
102
101
}
103
102
104
103
return null ;
@@ -113,8 +112,7 @@ public function search($value, bool $strict = false): ?Enum
113
112
public function contains ($ enumerator ): bool
114
113
{
115
114
try {
116
- $ enumeration = $ this ->enumeration ;
117
- $ ord = $ enumeration ::get ($ enumerator )->getOrdinal ();
115
+ $ ord = ($ this ->enumeration )::get ($ enumerator )->getOrdinal ();
118
116
return array_key_exists ($ ord , $ this ->map );
119
117
} catch (InvalidArgumentException $ e ) {
120
118
// An invalid enumerator can't be contained in this map
@@ -131,9 +129,7 @@ public function contains($enumerator): bool
131
129
public function offsetExists ($ enumerator ): bool
132
130
{
133
131
try {
134
- $ enumeration = $ this ->enumeration ;
135
- $ ord = $ enumeration ::get ($ enumerator )->getOrdinal ();
136
- return isset ($ this ->map [$ ord ]);
132
+ return isset ($ this ->map [($ this ->enumeration )::get ($ enumerator )->getOrdinal ()]);
137
133
} catch (InvalidArgumentException $ e ) {
138
134
// An invalid enumerator can't be an offset of this map
139
135
return false ;
@@ -149,8 +145,7 @@ public function offsetExists($enumerator): bool
149
145
*/
150
146
public function offsetGet ($ enumerator )
151
147
{
152
- $ enumeration = $ this ->enumeration ;
153
- $ enumerator = $ enumeration ::get ($ enumerator );
148
+ $ enumerator = ($ this ->enumeration )::get ($ enumerator );
154
149
$ ord = $ enumerator ->getOrdinal ();
155
150
if (!isset ($ this ->map [$ ord ]) && !array_key_exists ($ ord , $ this ->map )) {
156
151
throw new UnexpectedValueException (sprintf (
@@ -172,8 +167,7 @@ public function offsetGet($enumerator)
172
167
*/
173
168
public function offsetSet ($ enumerator , $ value = null ): void
174
169
{
175
- $ enumeration = $ this ->enumeration ;
176
- $ ord = $ enumeration ::get ($ enumerator )->getOrdinal ();
170
+ $ ord = ($ this ->enumeration )::get ($ enumerator )->getOrdinal ();
177
171
178
172
if (!array_key_exists ($ ord , $ this ->map )) {
179
173
$ this ->ordinals [] = $ ord ;
@@ -190,8 +184,7 @@ public function offsetSet($enumerator, $value = null): void
190
184
*/
191
185
public function offsetUnset ($ enumerator ): void
192
186
{
193
- $ enumeration = $ this ->enumeration ;
194
- $ ord = $ enumeration ::get ($ enumerator )->getOrdinal ();
187
+ $ ord = ($ this ->enumeration )::get ($ enumerator )->getOrdinal ();
195
188
196
189
if (($ idx = \array_search ($ ord , $ this ->ordinals , true )) !== false ) {
197
190
unset($ this ->map [$ ord ], $ this ->ordinals [$ idx ]);
@@ -237,8 +230,7 @@ public function key(): ?Enum
237
230
return null ;
238
231
}
239
232
240
- $ enumeration = $ this ->enumeration ;
241
- return $ enumeration ::byOrdinal ($ this ->ordinals [$ this ->pos ]);
233
+ return ($ this ->enumeration )::byOrdinal ($ this ->ordinals [$ this ->pos ]);
242
234
}
243
235
244
236
/**
0 commit comments