/** * Calls an internal member function of a set member with arguments * * Like map, only it calls a particular method on the given object, * this is possible because the set can be guaranteed to hold only * certain objects. Do not attempt on a mixed set. * * @param string $method The method name to call * @param array $args The arguments to pass to the method * @param Falcraft\Data\Types\Set $S The set to act on * */ public static function mapInternal($method, $args, RestrictedSet $S) { foreach ($S->iterate() as $object) { if (method_exists($object, $method)) { call_user_func_array(array($object, $method), $args); } } }
echo "Size of Set -> "; $success = true; $count = null; try { $count = $testRestrictedSet->size(); } catch (\Exception $e) { $success = false; } if ($success) { echo "Success! ({$count})\n"; } else { echo "Failure...\n"; } echo "Iteration -- \n"; try { foreach ($testRestrictedSet->iterate() as $setValue) { echo " \$setValue - {$setValue}\n"; } } catch (\Exception $e) { echo "EXCEPTION CAUGHT\n"; } echo "Hashing -> "; $success = true; $hash = $hash2 = null; try { $hash = $testRestrictedSet->hash(); $testRestrictedSet->add(7); $hash2 = $testRestrictedSet->hash(); } catch (\Exception $e) { $success = false; }