public function get() { $storage = new \SplObjectStorage(); $storage->attach($this->exampleA); $storage->attach($this->exampleB); return $storage; }
/** * Adds a new validator to the conjunction. * * @param \TYPO3\FLOW3\Validation\Validator\ValidatorInterface $validator The validator that should be added * @return void * @api */ public function addValidator(\TYPO3\FLOW3\Validation\Validator\ValidatorInterface $validator) { if ($validator instanceof ObjectValidatorInterface) { $validator->setValidatedInstancesContainer = $this->validatedInstancesContainer; } $this->validators->attach($validator); }
public function __construct(array $users = array()) { $this->users = new SplObjectStorage(); foreach ($users as $user) { $this->users->attach(new User(new UserId($user['id']), new Name($user['name']), new EmailAddress($user['email']))); } }
public function __construct(\SplObjectStorage $fieldGroups, \SplObjectStorage $fields, array $fieldGroupsArray = array(), array $fieldsArray = array()) { $this->fields = $fields; $this->fieldGroups = $fieldGroups; if (!empty($fieldsArray)) { foreach ($fieldsArray as $field) { if (!$field instanceof AbstractFieldProxy) { $message = "One or more of the fields you have passed to "; $message .= get_class($this); $message .= " does not extend the FieldProxy class."; throw new \RuntimeException($message); } $this->fields->attach($field); } } if (!empty($fieldGroupsArray)) { foreach ($fieldGroupsArray as $fieldGroup) { if (!$fieldGroup instanceof AbstractFieldGroup) { $message = "One or more of the fields you have passed to "; $message .= get_class($this); $message .= " does not extend the FieldGroup class."; throw new \RuntimeException($message); } $this->fieldGroups->attach($fieldGroup); } } }
/** * {@inheritdoc} */ public function execute(ImmediateInterface $immediate) { if (!$this->immediates->contains($immediate)) { $this->queue->push($immediate); $this->immediates->attach($immediate); } }
/** * @param ConnectionInterface $connection */ public function add(ConnectionInterface $connection) { Debug::line(__CLASS__ . ': Add ['); $this->storage->attach($connection); Debug::line('-- WebSocket connection added'); Debug::line(']'); }
function it_should_process_the_tiebreaker_round_and_return_the_loser() { // less $answer1 = json_decode('{"answer":0.019,"token":"token-goes-here"}'); $answer2 = json_decode('{"answer":0.020,"token":"token-goes-here"}'); // more $answer3 = json_decode('{"answer":0.021,"token":"token-goes-here"}'); $answer4 = json_decode('{"answer":0.020,"token":"token-goes-here"}'); // equal $answer5 = json_decode('{"answer":0.020,"token":"token-goes-here"}'); $answer6 = json_decode('{"answer":0.020,"token":"token-goes-here"}'); // create Dummy objects $clients = new \SplObjectStorage(); $conn1 = new \StdClass(); $conn2 = new \StdClass(); // less - answer1 wins $clients->attach($conn1, $answer1); $clients->attach($conn2, $answer2); $this->processTiebreaker($clients)->shouldReturn($conn2); // more - answer2 wins $clients->attach($conn1, $answer3); $clients->attach($conn2, $answer4); $this->processTiebreaker($clients)->shouldReturn($conn1); // equal - answer1 wins ( I know its cheating a little ) $clients->attach($conn1, $answer5); $clients->attach($conn2, $answer6); $this->processTiebreaker($clients)->shouldReturn($conn2); }
public static function getMultiplePairsExtensions() { $extensions = new \SplObjectStorage(); $extensions->attach(IRI::fromString('http://id.tincanapi.com/extension/topic'), 'Conformance Testing'); $extensions->attach(IRI::fromString('http://id.tincanapi.com/extension/color'), array('model' => 'RGB', 'value' => '#FFFFFF')); $extensions->attach(IRI::fromString('http://id.tincanapi.com/extension/starting-position'), 1); return new Extensions($extensions); }
/** * @inheritDoc */ public function addListener(ListenerInterface ...$listeners) { foreach ($listeners as $listener) { if (!$this->listeners->contains($listener)) { $this->listeners->attach($listener); } } }
/** * @param FormInterface $child * @return FormInterface */ public function add(FormInterface $child) { if (FALSE === $this->children->contains($child)) { $this->children->attach($child); $child->setParent($this); } return $this; }
/** * Adds scope to default scopes * * @param IScope $scope */ public function addDefaultScope(IScope $scope) { if (!$this->defaultScopes->contains($scope)) { $this->defaultScopes->attach($scope); } else { throw new \InvalidArgumentException("Scope '{$scope->getId()}' is already registered as default scope."); } }
public function where(CompilableInterface $expr, $operator = 'AND') { if (!in_array($operator, ['AND', 'OR'])) { throw new InvalidArgumentException(sprintf("The operator must be one of: AND, OR, but got '%s'", $operator)); } $this->where->attach($expr, $operator); return $this; }
public function then(callable $onFulfilled = null, callable $onRejected = null) { $child = new Promise($this->promise); $this->onFulfilled->attach($child, $onFulfilled); $this->onRejected->attach($child, $onRejected); $this->children[] = $child; return $child; }
public function testGetExceptions() { $exceptions = new \SplObjectStorage(); $exceptions->attach(new \Exception()); $exceptions->attach(new \Exception()); $result = new Result('export', new \DateTime(), new \DateTime(), 10, $exceptions); $this->assertSame($exceptions, $result->getExceptions()); }
/** * {@inheritdoc} */ public function getValues() : PromiseInterface { $counters = $this->infoProvider->getCounters(); $storage = new \SplObjectStorage(); $storage->attach(new Metric('current_read_streams', (double) $counters['streams']['read']['current'])); $storage->attach(new Metric('current_write_streams', (double) $counters['streams']['write']['current'])); return resolve($storage); }
/** * @param \Icicle\Postgres\Connection $connection */ protected function addConnection(Connection $connection) { if (isset($this->connections[$connection])) { return; } $this->connections->attach($connection); $this->idle->push($connection); }
/** * Adds a new validator to the conjunction. * * @param \TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface $validator The validator that should be added * @return void * @api */ public function addValidator(\TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface $validator) { if ($validator instanceof ObjectValidatorInterface) { // @todo: provide bugfix as soon as it is fixed in TYPO3.Flow (http://forge.typo3.org/issues/48093) $validator->setValidatedInstancesContainer = $this->validatedInstancesContainer; } $this->validators->attach($validator); }
public function spl_object_storage_can_be_used_like_a_set() { $spl_storage = new SplObjectStorage(); $an_object = new ClassWithProperties(); $spl_storage->attach($an_object); $spl_storage->attach($an_object); assert_that(count($spl_storage))->is_identical_to(__); }
public function addChannel(Channel $channel) { if (isset($this->channelNames[$channel->getName()])) { return; } $this->channelNames[$channel->getName()] = true; $this->collection->attach($channel); }
/** * @return \Nano\Event\Manager * @param \Nano\Event\Handler $handler */ public function attachHandler(\Nano\Event\Handler $handler) { if ($this->handlers->contains($handler)) { return $this; } $this->handlers->attach($handler); return $this; }
/** * Set master and slaves. * * @param $master * @param array ...$slaves */ protected function init($master, ...$slaves) { $this->master = $master; $this->slaves = new \SplObjectStorage(); foreach ($slaves as $slave) { $this->slaves->attach($slave); } }
public function __construct() { $this->users = new SplObjectStorage(); $this->users->attach(new User(1034, 'Rafael', '*****@*****.**')); $this->users->attach(new User(1035, 'Donatello', '*****@*****.**')); $this->users->attach(new User(1036, 'Michelangelo', '*****@*****.**')); $this->users->attach(new User(1037, 'Leonardo', '*****@*****.**')); }
/** * Adds the specific strategy of error handling. * * @param \Es\Error\Strategy\AbstractErrorStrategy $strategy The strategy */ public function attachErrorStrategy(AbstractErrorStrategy $strategy) { if ($strategy instanceof HtmlErrorStrategy) { $this->setDefaultErrorStrategy($strategy); return; } $this->strategies->attach($strategy); }
public function startVisiting($object) { if (!is_object($object)) { return; } $this->visitingSet->attach($object); $this->visitingStack->push($object); }
/** * {@inheritdoc} */ public function onOpen(ConnectionInterface $conn) { if (!$this->getContext($conn)->isValid()) { $conn->close(); } else { $this->clients->attach($conn); } }
/** * @param MailboxService $mailbox * * @return bool */ public function attach(MailboxService $mailbox) { if ($this->contains($mailbox) === true) { return false; } $this->mailboxes->attach($mailbox); return true; }
/** * * @param TransitionInterface $transition */ public function addTransition(TransitionInterface $transition) { $this->transitions->attach($transition); $eventName = $transition->getEventName(); if ($eventName) { $this->getEvent($eventName); } }
/** * @param object $object * @return void */ public function addObject($object, $data = NULL) { if ($data === NULL) { $this->objects->attach($object); } else { $this->objects[$object] = $data; } }
public function onStartVertex($vertex, \Closure $visit) { parent::onStartVertex($vertex, $visit); $this->active->attach($vertex); if (!isset($this->paths[$vertex])) { $this->paths[$vertex] = array(); } }
/** * 添加观察者 * @param \SplObserver $observer */ function attach(\SplObserver $observer) { if ($this->_observers == null) { $this->_observers = new \SplObjectStorage(); } $this->_observers->attach($observer); }