@@ -187,7 +187,7 @@ class User
187
187
}
188
188
```
189
189
190
- * Makes sure the resulting enumerator exactly matches an enumeration. (Inherited enumerators as not allowed).
190
+ * Makes sure the resulting enumerator exactly matches an enumeration. (Inherited enumerators are not allowed).
191
191
192
192
* Allows enumerator values directly
193
193
* ` $user->setStatus(UserStatus::ACTIVE) ` works
@@ -216,8 +216,7 @@ ordinal number by design.
216
216
It implements ` IteratorAggregate ` and ` Countable ` to be directly iterable with ` foreach ` and countable with ` count() ` .
217
217
218
218
The ` EnumSet ` has a mutable and an immutable interface.
219
- Mutable methods starts with ` set ` , ` attach ` and ` detach ` .
220
- Immutable methods starts with ` with ` or ` without ` .
219
+ Mutable methods starts with ` set ` or ` remove ` where immutable methods starts with ` with ` .
221
220
222
221
``` php
223
222
use MabeEnum\EnumSet;
@@ -227,36 +226,36 @@ $enumSet = new EnumSet('UserStatus', [UserStatus::ACTIVE()]);
227
226
228
227
// modify an EnumSet (mutable interface)
229
228
230
- // attach enumerators (by value or by instance)
231
- $enumSet->attachEnumerators ([UserStatus::INACTIVE, UserStatus::DELETED()]);
229
+ // add enumerators (by value or by instance)
230
+ $enumSet->addIterable ([UserStatus::INACTIVE, UserStatus::DELETED()]);
232
231
// or
233
- $enumSet->attachEnumerator (UserStatus::INACTIVE);
234
- $enumSet->attachEnumerator (UserStatus::DELETED());
232
+ $enumSet->add (UserStatus::INACTIVE);
233
+ $enumSet->add (UserStatus::DELETED());
235
234
236
- // detach enumerators (by value or by instance)
237
- $enumSet->detachEnumerators ([UserStatus::INACTIVE, UserStatus::DELETED()]);
235
+ // remove enumerators (by value or by instance)
236
+ $enumSet->removeIterable ([UserStatus::INACTIVE, UserStatus::DELETED()]);
238
237
// or
239
- $enumSet->detachEnumerator (UserStatus::INACTIVE);
240
- $enumSet->detachEnumerator (UserStatus::DELETED());
238
+ $enumSet->remove (UserStatus::INACTIVE);
239
+ $enumSet->remove (UserStatus::DELETED());
241
240
242
241
243
242
// The immutable interface will create a new EnumSet for each modification
244
243
245
244
// add enumerators (by value or by instance)
246
- $enumSet = $enumSet->withEnumerators ([UserStatus::INACTIVE, UserStatus::DELETED()]);
245
+ $enumSet = $enumSet->withIterable ([UserStatus::INACTIVE, UserStatus::DELETED()]);
247
246
// or
248
- $enumSet = $enumSet->withEnumerator (UserStatus::INACTIVE);
249
- $enumSet = $enumSet->withEnumerator (UserStatus::DELETED());
247
+ $enumSet = $enumSet->with (UserStatus::INACTIVE);
248
+ $enumSet = $enumSet->with (UserStatus::DELETED());
250
249
251
- // detach enumerators (by value or by instance)
252
- $enumSet->withoutEnumerators ([UserStatus::INACTIVE, UserStatus::DELETED()]);
250
+ // remove enumerators (by value or by instance)
251
+ $enumSet->withoutIterable ([UserStatus::INACTIVE, UserStatus::DELETED()]);
253
252
// or
254
- $enumSet = $enumSet->withEnumerator (UserStatus::INACTIVE);
255
- $enumSet = $enumSet->withEnumerator (UserStatus::DELETED());
253
+ $enumSet = $enumSet->without (UserStatus::INACTIVE);
254
+ $enumSet = $enumSet->without (UserStatus::DELETED());
256
255
257
256
258
- // contains enumerators (by value or by instance)
259
- $enumSet->contains (UserStatus::INACTIVE); // bool
257
+ // Tests if an enumerator exists (by value or by instance)
258
+ $enumSet->has (UserStatus::INACTIVE); // bool
260
259
261
260
262
261
// count the number of enumerators
@@ -347,14 +346,14 @@ count($enumMap);
347
346
348
347
// support for null aware exists check
349
348
$enumMap[UserStatus::NULL] = null;
350
- isset($enumMap[UserStatus::NULL]); // false
351
- $enumMap->contains (UserStatus::NULL); // true
349
+ isset($enumMap[UserStatus::NULL]); // false
350
+ $enumMap->has (UserStatus::NULL); // true
352
351
353
352
354
353
// iterating over the map
355
354
foreach ($enumMap as $enum => $value) {
356
355
get_class($enum); // UserStatus (enumerator object)
357
- gettype($value); // string (the value the enumerators maps to)
356
+ gettype($value); // mixed (the value the enumerators maps to)
358
357
}
359
358
360
359
// get a list of keys (= a list of enumerator objects)
@@ -415,6 +414,11 @@ var_dump($north2->is($north1)); // returns TRUE - equality works in both directi
415
414
* No support for ` EnumMap ` or ` EnumSet ` .
416
415
417
416
417
+ # Changelog
418
+
419
+ Changes are documented in the (release page)[ https://github.com/marc-mabe/php-enum/releases ] .
420
+
421
+
418
422
# Install
419
423
420
424
## Composer
0 commit comments