public function push(CompositableInterface $entity): DocumentCompositor
    {
        //Detaching entity
        $entity = clone $entity;

        $this->assertSupported($entity);

        $this->entities[] = $entity;
        $this->atomics['$push'][] = $entity;

        return $this;
    }
public function push(CompositableInterface $entity): DocumentCompositor
    {
        //Detaching entity
        $entity = clone $entity;

        $this->assertSupported($entity);

        $this->entities[] = $entity;
        $this->atomics['$push'][] = $entity;

        return $this;
    }
public function push ( CompositableInterface $ entity ) : DocumentCompositor { //Detaching entity $ entity = clone $ entity ; $ this -> assertSupported ( $ entity ) ; $ this -> entities [ ] = $ entity ; $ this -> atomics [ '$push' ] [ ] = $ entity ; return $ this ; }
Push new entity to end of set.

Be aware that any added entity will be cloned in order to detach it from passed object:
$user->addresses->push($address);
$address->city = 'Minsk'; //this will have no effect of $user->addresses

@param CompositableInterface $entity

@return DocumentCompositor

@throws CompositorException When entity is invalid type.
Push new entity to end of set .