/** * {@inheritDoc} */ public function addListener($eventName, callable $callable) { if (!$this->listeners->containsKey($eventName)) { $this->listeners->add(new Pair($eventName, new Vector())); } $this->listeners->get($eventName)->add($callable); }
public function addFeature(FeatureInterface $feature) { if ($this->has($feature->getName())) { throw new FeatureAlreadyExistsException(sprintf('The feature %s already exists', $feature->getName())); } $this->features->add($feature->getName(), $feature); return $this; }
/** * @test */ public function is_should_concatenate_vectors() { if ($this->coll instanceof MapInterface) { $this->coll->add(new Pair(0, 1))->add(new Pair(1, 2))->add(new Pair(3, 4)); } else { $this->coll->add(1)->add(2)->add(4); } $coll2 = new Vector([3]); $concatenated = $this->coll->concat($coll2); $this->assertEquals([1, 2, 4, 3], $concatenated->toArray()); }
public function save(StreamName $streamName, DomainMessage $event) { $id = (string) $event->getId(); $name = (string) $streamName; $events = $this->events->get($name); if (null === $events) { $events = new Map(); $this->events->add(new Pair($name, $events)); } if (!$events->containsKey($id)) { $events->add(new Pair($id, new Vector())); } $events->get($id)->add($event); }
public function save(Snapshot $snapshot) { $this->snapshots->add(new Pair((string) $snapshot->getAggregateId(), $snapshot)); }