} if ($success) { echo "Success:\n\n"; var_dump($result); echo "\n"; } else { echo "Failure...\n"; } echo "Set Map -> "; $success = true; $map = $result = null; try { $map = function ($test) { return $test + 1; }; $result = Types\Set::map($map, $testSet); } catch (\Exception $e) { $success = false; } if ($success) { echo "Success:\n\n"; var_dump($result); echo "\n"; } else { echo "Failure...\n"; } echo "Set Walk -> "; $success = true; $walk = null; try { $walk = function (&$elem, $key, $prefix) {
/** * Set all children (outgoing) of the node * * This disconnects all current children of the node, and then connects * the node to the given array (turned RestrictedSet). * * @see connectIncoming() * * @param array (of Falcraft\Data\Types\Resource\VertexInterface) of new parents * */ public function setOutgoing(array $outgoing = array()) { $outgoing = RestrictedSet::build($outgoing, $this->restrictions, array('strict' => true)); Set::map(array($this, 'disconnectOutgoing'), $this->outgoing); foreach ($this->outgoing->iterate() as $vertex) { $vertex->disconnectIncoming($this); } Set::map(array($this, 'connectOutgoing'), $outgoing); foreach ($outgoing->iterate() as $vertex) { $vertex->connectIncoming($this); } }
/** * Set all children (outgoing) of the node * * This disconnects all current children of the node, and then connects * the node to the given array (turned RestrictedSet). * * @see connectIncoming() * * @param array (of Falcraft\Data\Types\Resource\VertexInterface) of new parents * */ public function setOutgoing(array $outgoing = array()) { /* $outgoing = RestrictedSet::build($outgoing->, $this->restrictions, array( 'strict' => true )); */ Set::map(array($this, 'disconnectOutgoing'), new Set($this->outgoing->getVerticesAsArray(), array('strict' => true))); foreach ($this->outgoing->getVerticesAsArray() as $vertex) { $vertex->disconnectIncoming($this); } Set::map(array($this, 'connectOutgoing'), new Set($outgoing, array('strict' => true))); foreach ($outgoing as $vertex) { $vertex->connectIncoming($this); } $outgoing = new VertexList($outgoing); }