src/Collection.php
public function add(ElementInterface $element)
    {
        $id = $element->id;

        if ($id === null) $id = $this->generateId();

        $element->id = $id;

        $this->checkId($id);

        $this->objects[] = $element;

        if (count($this->objects) === 1) {
            array_unshift($this->objects, 'pseudo');
            unset($this->objects[0]);
        }

        $this->ids[array_search($element, $this->objects, true)] = $id;
    }
public function add(ElementInterface $element)
    {
        $id = $element->id;

        if ($id === null) $id = $this->generateId();

        $element->id = $id;

        $this->checkId($id);

        $this->objects[] = $element;

        if (count($this->objects) === 1) {
            array_unshift($this->objects, 'pseudo');
            unset($this->objects[0]);
        }

        $this->ids[array_search($element, $this->objects, true)] = $id;
    }
Add an element to the collection

@param ElementInterface $element