@@ 233-251 (lines=19) @@ | ||
230 | * @param EnumSet ...$other Other EnumSet(s) of the same enumeration to produce the union |
|
231 | * @return EnumSet |
|
232 | */ |
|
233 | public function union(EnumSet $other) |
|
234 | { |
|
235 | $bitset = $this->bitset; |
|
236 | foreach (func_get_args() as $other) { |
|
237 | if (!$other instanceof self || $this->enumeration !== $other->enumeration) { |
|
238 | throw new InvalidArgumentException(sprintf( |
|
239 | "Others should be an instance of %s of the same enumeration as this %s", |
|
240 | __CLASS__, |
|
241 | $this->enumeration |
|
242 | )); |
|
243 | } |
|
244 | ||
245 | $bitset |= $other->bitset; |
|
246 | } |
|
247 | ||
248 | $clone = clone $this; |
|
249 | $clone->bitset = $bitset; |
|
250 | return $clone; |
|
251 | } |
|
252 | ||
253 | /** |
|
254 | * Produce a new set with enumerators common to both this and other (this & other) |
|
@@ 258-276 (lines=19) @@ | ||
255 | * @param EnumSet ...$other Other EnumSet(s) of the same enumeration to produce the union |
|
256 | * @return EnumSet |
|
257 | */ |
|
258 | public function intersect(EnumSet $other) |
|
259 | { |
|
260 | $bitset = $this->bitset; |
|
261 | foreach (func_get_args() as $other) { |
|
262 | if (!$other instanceof self || $this->enumeration !== $other->enumeration) { |
|
263 | throw new InvalidArgumentException(sprintf( |
|
264 | "Others should be an instance of %s of the same enumeration as this %s", |
|
265 | __CLASS__, |
|
266 | $this->enumeration |
|
267 | )); |
|
268 | } |
|
269 | ||
270 | $bitset &= $other->bitset; |
|
271 | } |
|
272 | ||
273 | $clone = clone $this; |
|
274 | $clone->bitset = $bitset; |
|
275 | return $clone; |
|
276 | } |
|
277 | ||
278 | /** |
|
279 | * Produce a new set with enumerators in this but not in other (this - other) |
|
@@ 283-301 (lines=19) @@ | ||
280 | * @param EnumSet ...$other Other EnumSet(s) of the same enumeration to produce the union |
|
281 | * @return EnumSet |
|
282 | */ |
|
283 | public function diff(EnumSet $other) |
|
284 | { |
|
285 | $bitset = ''; |
|
286 | foreach (func_get_args() as $other) { |
|
287 | if (!$other instanceof self || $this->enumeration !== $other->enumeration) { |
|
288 | throw new InvalidArgumentException(sprintf( |
|
289 | "Others should be an instance of %s of the same enumeration as this %s", |
|
290 | __CLASS__, |
|
291 | $this->enumeration |
|
292 | )); |
|
293 | } |
|
294 | ||
295 | $bitset |= $other->bitset; |
|
296 | } |
|
297 | ||
298 | $clone = clone $this; |
|
299 | $clone->bitset = $this->bitset & ~$bitset; |
|
300 | return $clone; |
|
301 | } |
|
302 | ||
303 | /** |
|
304 | * Produce a new set with enumerators in either this and other but not in both (this ^ (other | other)) |
|
@@ 308-326 (lines=19) @@ | ||
305 | * @param EnumSet ...$other Other EnumSet(s) of the same enumeration to produce the union |
|
306 | * @return EnumSet |
|
307 | */ |
|
308 | public function symDiff(EnumSet $other) |
|
309 | { |
|
310 | $bitset = ''; |
|
311 | foreach (func_get_args() as $other) { |
|
312 | if (!$other instanceof self || $this->enumeration !== $other->enumeration) { |
|
313 | throw new InvalidArgumentException(sprintf( |
|
314 | "Others should be an instance of %s of the same enumeration as this %s", |
|
315 | __CLASS__, |
|
316 | $this->enumeration |
|
317 | )); |
|
318 | } |
|
319 | ||
320 | $bitset |= $other->bitset; |
|
321 | } |
|
322 | ||
323 | $clone = clone $this; |
|
324 | $clone->bitset = $this->bitset ^ $bitset; |
|
325 | return $clone; |
|
326 | } |
|
327 | ||
328 | /** |
|
329 | * Get ordinal numbers of the defined enumerators as array |
@@ 215-233 (lines=19) @@ | ||
212 | * @param EnumSet ...$other Other EnumSet(s) of the same enumeration to produce the union |
|
213 | * @return EnumSet |
|
214 | */ |
|
215 | public function union(EnumSet $other) |
|
216 | { |
|
217 | $bitset = $this->bitset; |
|
218 | foreach (func_get_args() as $other) { |
|
219 | if (!$other instanceof self || $this->enumeration !== $other->enumeration) { |
|
220 | throw new InvalidArgumentException(sprintf( |
|
221 | "Others should be an instance of %s of the same enumeration as this %s", |
|
222 | __CLASS__, |
|
223 | $this->enumeration |
|
224 | )); |
|
225 | } |
|
226 | ||
227 | $bitset |= $other->bitset; |
|
228 | } |
|
229 | ||
230 | $clone = clone $this; |
|
231 | $clone->bitset = $bitset; |
|
232 | return $clone; |
|
233 | } |
|
234 | ||
235 | /** |
|
236 | * Produce a new set with enumerators common to both this and other (this & other) |
|
@@ 240-258 (lines=19) @@ | ||
237 | * @param EnumSet ...$other Other EnumSet(s) of the same enumeration to produce the union |
|
238 | * @return EnumSet |
|
239 | */ |
|
240 | public function intersect(EnumSet $other) |
|
241 | { |
|
242 | $bitset = $this->bitset; |
|
243 | foreach (func_get_args() as $other) { |
|
244 | if (!$other instanceof self || $this->enumeration !== $other->enumeration) { |
|
245 | throw new InvalidArgumentException(sprintf( |
|
246 | "Others should be an instance of %s of the same enumeration as this %s", |
|
247 | __CLASS__, |
|
248 | $this->enumeration |
|
249 | )); |
|
250 | } |
|
251 | ||
252 | $bitset &= $other->bitset; |
|
253 | } |
|
254 | ||
255 | $clone = clone $this; |
|
256 | $clone->bitset = $bitset; |
|
257 | return $clone; |
|
258 | } |
|
259 | ||
260 | /** |
|
261 | * Produce a new set with enumerators in this but not in other (this - other) |
|
@@ 265-283 (lines=19) @@ | ||
262 | * @param EnumSet ...$other Other EnumSet(s) of the same enumeration to produce the union |
|
263 | * @return EnumSet |
|
264 | */ |
|
265 | public function diff(EnumSet $other) |
|
266 | { |
|
267 | $bitset = ''; |
|
268 | foreach (func_get_args() as $other) { |
|
269 | if (!$other instanceof self || $this->enumeration !== $other->enumeration) { |
|
270 | throw new InvalidArgumentException(sprintf( |
|
271 | "Others should be an instance of %s of the same enumeration as this %s", |
|
272 | __CLASS__, |
|
273 | $this->enumeration |
|
274 | )); |
|
275 | } |
|
276 | ||
277 | $bitset |= $other->bitset; |
|
278 | } |
|
279 | ||
280 | $clone = clone $this; |
|
281 | $clone->bitset = $this->bitset & ~$bitset; |
|
282 | return $clone; |
|
283 | } |
|
284 | ||
285 | /** |
|
286 | * Produce a new set with enumerators in either this and other but not in both (this ^ (other | other)) |
|
@@ 290-308 (lines=19) @@ | ||
287 | * @param EnumSet ...$other Other EnumSet(s) of the same enumeration to produce the union |
|
288 | * @return EnumSet |
|
289 | */ |
|
290 | public function symDiff(EnumSet $other) |
|
291 | { |
|
292 | $bitset = ''; |
|
293 | foreach (func_get_args() as $other) { |
|
294 | if (!$other instanceof self || $this->enumeration !== $other->enumeration) { |
|
295 | throw new InvalidArgumentException(sprintf( |
|
296 | "Others should be an instance of %s of the same enumeration as this %s", |
|
297 | __CLASS__, |
|
298 | $this->enumeration |
|
299 | )); |
|
300 | } |
|
301 | ||
302 | $bitset |= $other->bitset; |
|
303 | } |
|
304 | ||
305 | $clone = clone $this; |
|
306 | $clone->bitset = $this->bitset ^ $bitset; |
|
307 | return $clone; |
|
308 | } |
|
309 | ||
310 | /** |
|
311 | * Get ordinal numbers of the defined enumerators as array |
@@ 346-364 (lines=19) @@ | ||
343 | * @param EnumSet ...$other Other EnumSet(s) of the same enumeration to produce the union |
|
344 | * @return EnumSet |
|
345 | */ |
|
346 | public function union(EnumSet $other) |
|
347 | { |
|
348 | $bitset = $this->bitset; |
|
349 | foreach (func_get_args() as $other) { |
|
350 | if (!$other instanceof self || $this->enumeration !== $other->enumeration) { |
|
351 | throw new InvalidArgumentException(sprintf( |
|
352 | "Others should be an instance of %s of the same enumeration as this %s", |
|
353 | __CLASS__, |
|
354 | $this->enumeration |
|
355 | )); |
|
356 | } |
|
357 | ||
358 | $bitset |= $other->bitset; |
|
359 | } |
|
360 | ||
361 | $clone = clone $this; |
|
362 | $clone->bitset = $bitset; |
|
363 | return $clone; |
|
364 | } |
|
365 | ||
366 | /** |
|
367 | * Produce a new set with enumerators common to both this and other (this & other) |
|
@@ 371-389 (lines=19) @@ | ||
368 | * @param EnumSet ...$other Other EnumSet(s) of the same enumeration to produce the union |
|
369 | * @return EnumSet |
|
370 | */ |
|
371 | public function intersect(EnumSet $other) |
|
372 | { |
|
373 | $bitset = $this->bitset; |
|
374 | foreach (func_get_args() as $other) { |
|
375 | if (!$other instanceof self || $this->enumeration !== $other->enumeration) { |
|
376 | throw new InvalidArgumentException(sprintf( |
|
377 | "Others should be an instance of %s of the same enumeration as this %s", |
|
378 | __CLASS__, |
|
379 | $this->enumeration |
|
380 | )); |
|
381 | } |
|
382 | ||
383 | $bitset &= $other->bitset; |
|
384 | } |
|
385 | ||
386 | $clone = clone $this; |
|
387 | $clone->bitset = $bitset; |
|
388 | return $clone; |
|
389 | } |
|
390 | ||
391 | /** |
|
392 | * Produce a new set with enumerators in this but not in other (this - other) |
|
@@ 396-414 (lines=19) @@ | ||
393 | * @param EnumSet ...$other Other EnumSet(s) of the same enumeration to produce the union |
|
394 | * @return EnumSet |
|
395 | */ |
|
396 | public function diff(EnumSet $other) |
|
397 | { |
|
398 | $bitset = $other->bitset; |
|
399 | foreach (func_get_args() as $other) { |
|
400 | if (!$other instanceof self || $this->enumeration !== $other->enumeration) { |
|
401 | throw new InvalidArgumentException(sprintf( |
|
402 | "Others should be an instance of %s of the same enumeration as this %s", |
|
403 | __CLASS__, |
|
404 | $this->enumeration |
|
405 | )); |
|
406 | } |
|
407 | ||
408 | $bitset |= $other->bitset; |
|
409 | } |
|
410 | ||
411 | $clone = clone $this; |
|
412 | $clone->bitset = $this->bitset & ~$bitset; |
|
413 | return $clone; |
|
414 | } |
|
415 | ||
416 | /** |
|
417 | * Produce a new set with enumerators in either this and other but not in both (this ^ (other | other)) |
|
@@ 421-439 (lines=19) @@ | ||
418 | * @param EnumSet ...$other Other EnumSet(s) of the same enumeration to produce the union |
|
419 | * @return EnumSet |
|
420 | */ |
|
421 | public function symDiff(EnumSet $other) |
|
422 | { |
|
423 | $bitset = $other->bitset; |
|
424 | foreach (func_get_args() as $other) { |
|
425 | if (!$other instanceof self || $this->enumeration !== $other->enumeration) { |
|
426 | throw new InvalidArgumentException(sprintf( |
|
427 | "Others should be an instance of %s of the same enumeration as this %s", |
|
428 | __CLASS__, |
|
429 | $this->enumeration |
|
430 | )); |
|
431 | } |
|
432 | ||
433 | $bitset |= $other->bitset; |
|
434 | } |
|
435 | ||
436 | $clone = clone $this; |
|
437 | $clone->bitset = $this->bitset ^ $bitset; |
|
438 | return $clone; |
|
439 | } |
|
440 | ||
441 | /** |
|
442 | * Get ordinal numbers of the defined enumerators as array |