MabeEnum\EnumSet::intersect PHP Method

intersect() public method

Produce a new set with enumerators common to both this and other (this & other)
public intersect ( EnumSet $other ) : EnumSet
$other EnumSet Other EnumSet(s) of the same enumeration to produce the union
return EnumSet
    public function intersect(EnumSet $other)
    {
        $bitset = $this->bitset;
        foreach (func_get_args() as $other) {
            if (!$other instanceof self || $this->enumeration !== $other->enumeration) {
                throw new InvalidArgumentException(sprintf("Others should be an instance of %s of the same enumeration as this %s", __CLASS__, $this->enumeration));
            }
            $bitset &= $other->bitset;
        }
        $clone = clone $this;
        $clone->bitset = $bitset;
        return $clone;
    }