public function mergeWith(self $flags, bool $override = true): self
    {
        if ($override) {
            $clone = clone ($this);
            foreach ($flags as $stringFlag => $flag) {
                /** @var FlagInterface $flag */
                $clone->flags[$flag->__toString()] = clone ($flag);
            }
        } else {
            $clone = clone ($flags);
            $clone->key = $this->key;
            foreach ($this as $stringFlag => $flag) {
                /** @var FlagInterface $flag */
                $clone->flags[$flag->__toString()] = clone ($flag);
            }
        }

        return $clone;
    }
public function mergeWith(self $flags, bool $override = true): self
    {
        if ($override) {
            $clone = clone ($this);
            foreach ($flags as $stringFlag => $flag) {
                /** @var FlagInterface $flag */
                $clone->flags[$flag->__toString()] = clone ($flag);
            }
        } else {
            $clone = clone ($flags);
            $clone->key = $this->key;
            foreach ($this as $stringFlag => $flag) {
                /** @var FlagInterface $flag */
                $clone->flags[$flag->__toString()] = clone ($flag);
            }
        }

        return $clone;
    }
public function mergeWith ( self $ flags , bool $ override = true ) : self { if ( $ override ) { $ clone = clone ( $ this ) ; foreach ( $ flags as $ stringFlag => $ flag ) { /** @var FlagInterface $flag */ $ clone -> flags [ $ flag -> __toString ( ) ] = clone ( $ flag ) ; } } else { $ clone = clone ( $ flags ) ; $ clone -> key = $ this -> key ; foreach ( $ this as $ stringFlag => $ flag ) { /** @var FlagInterface $flag */ $ clone -> flags [ $ flag -> __toString ( ) ] = clone ( $ flag ) ; } } return $ clone ; }
Creates a new instance with the two bags merged together.

The original key is kept.

@param bool $override If some flags overlaps, the existing one are overridden if the value is true, and left
untouched otherwise.
Creates a new instance with the two bags merged together .