Example #1
0
 private function appendChildren(Aggregate $entity, CollectionInterface $children) : Aggregate
 {
     $children->each(function (string $name, array $config) use(&$entity) {
         $config = new Collection($config);
         $rel = new ValueObjectRelationship(new ClassName($config->get('class')), new RelationshipType($config->get('type')), $name, $config->get('child')['property'], $config->hasKey('collection') ? (bool) $config->get('collection') : false);
         if ($config->hasKey('properties')) {
             $rel = $this->appendProperties($rel, new Collection($config->get('properties')));
         }
         $config = new Collection($config->get('child'));
         $child = new ValueObject(new ClassName($config->get('class')), $config->get('labels'), $rel);
         if ($config->hasKey('properties')) {
             $child = $this->appendProperties($child, new Collection($config->get('properties')));
         }
         $entity = $entity->withChild($child);
     });
     return $entity;
 }
 public function testHasKeyRemoveClearIndexes()
 {
     $this->assertEquals(true, $this->collection->hasKey(3));
     $this->collection->remove(3);
     $this->assertEquals(false, $this->collection->hasKey(3));
 }