public function setEventStateObject(AbstractEvent $state, $morph = true) { if (!$state instanceof AbstractEvent) { throw new Exception\InvalidArgumentException('AbstractEvent->setStateObject: ' . 'state not instance of AbstractEvent'); } else { if ($morph) { $this->tags->clear(); $this->categories->clear(); $this->target = null; $this->data = null; $this->class = ''; $this->function = ''; $this->namespace = ''; } $this->identifier = $state->getIdentifier(); $this->{$field} = new Types\Set(Types\Set::union($state->getTags(), $this->{$field}), array('strict' => true)); $this->categories = new Types\Set(Types\Set::union($state->getCategories(), $this->{$field}), array('strict' => true)); $this->target = $state->getTarget(); $this->data = $state->getData(); $this->class = $state->getClass(); $this->function = $state->getFunction(); $this->namespace = $state->getNamespace(); } }
$success = false; } if ($success) { echo "Success:\n\n"; var_dump($testSet->getArray()); echo "\n"; } else { echo "Failure...\n"; } echo "Set Union -> "; $success = true; $result = null; try { $u1 = array(4, 2, 1); $u2 = array('baz', 'foo', 'bar'); $result = Types\Set::union($testSet, $u1, $u2); } catch (\Exception $e) { $success = false; } if ($success) { echo "Success:\n\n"; var_dump($result); echo "\n"; } else { echo "Failure...\n"; } echo "Set Intersection -> "; $success = true; $testSet = $otherTestSet = $testArray = $result = null; try { $testSet = Types\Set::build(array(1, 2, 3, 4, 5));