File tree Expand file tree Collapse file tree 3 files changed +8
-17
lines changed Expand file tree Collapse file tree 3 files changed +8
-17
lines changed Original file line number Diff line number Diff line change @@ -306,7 +306,7 @@ final public static function getNames(): array
306
306
final public static function getOrdinals (): array
307
307
{
308
308
$ count = \count (self ::detectConstants (static ::class));
309
- return $ count === 0 ? [] : \range (0 , $ count - 1 );
309
+ return $ count ? \range (0 , $ count - 1 ) : [] ;
310
310
}
311
311
312
312
/**
@@ -328,11 +328,8 @@ final public static function getConstants(): array
328
328
*/
329
329
final public static function has ($ enumerator ): bool
330
330
{
331
- if ($ enumerator instanceof static && \get_class ($ enumerator ) === static ::class) {
332
- return true ;
333
- }
334
-
335
- return static ::hasValue ($ enumerator );
331
+ return ($ enumerator instanceof static && \get_class ($ enumerator ) === static ::class)
332
+ || static ::hasValue ($ enumerator );
336
333
}
337
334
338
335
/**
Original file line number Diff line number Diff line change @@ -112,7 +112,7 @@ public function search($value, bool $strict = false): ?Enum
112
112
public function contains ($ enumerator ): bool
113
113
{
114
114
try {
115
- $ ord = ($ this ->enumeration )::get ($ enumerator )->getOrdinal ();
115
+ $ ord = ($ this ->enumeration )::get ($ enumerator )->getOrdinal ();
116
116
return array_key_exists ($ ord , $ this ->map );
117
117
} catch (InvalidArgumentException $ e ) {
118
118
// An invalid enumerator can't be contained in this map
Original file line number Diff line number Diff line change @@ -348,11 +348,8 @@ public function isEqual(EnumSet $other): bool
348
348
*/
349
349
public function isSubset (EnumSet $ other ): bool
350
350
{
351
- if ($ this ->enumeration !== $ other ->enumeration ) {
352
- return false ;
353
- }
354
-
355
- return ($ this ->bitset & $ other ->bitset ) === $ this ->bitset ;
351
+ return $ this ->enumeration === $ other ->enumeration
352
+ && ($ this ->bitset & $ other ->bitset ) === $ this ->bitset ;
356
353
}
357
354
358
355
/**
@@ -362,11 +359,8 @@ public function isSubset(EnumSet $other): bool
362
359
*/
363
360
public function isSuperset (EnumSet $ other ): bool
364
361
{
365
- if ($ this ->enumeration !== $ other ->enumeration ) {
366
- return false ;
367
- }
368
-
369
- return ($ this ->bitset | $ other ->bitset ) === $ this ->bitset ;
362
+ return $ this ->enumeration === $ other ->enumeration
363
+ && ($ this ->bitset | $ other ->bitset ) === $ this ->bitset ;
370
364
}
371
365
372
366
/**
You can’t perform that action at this time.
0 commit comments