public function addAt(Item $item, $position = null)
    {
        if (0 === $position) {
            array_unshift($this->items, $item);
        } else if (null === $position) {
            $this->items[] = $item;
        } else if (count($this->items) <= $position) {
            $this->items[] = $item;
        } else {
            array_splice($this->items, $position, 0, [$item]);
        }

        $this->isUpdated = true;

        return $this;
    }
public function addAt(Item $item, $position = null)
    {
        if (0 === $position) {
            array_unshift($this->items, $item);
        } else if (null === $position) {
            $this->items[] = $item;
        } else if (count($this->items) <= $position) {
            $this->items[] = $item;
        } else {
            array_splice($this->items, $position, 0, [$item]);
        }

        $this->isUpdated = true;

        return $this;
    }
public function addAt ( Item $ item , $ position = null ) { if ( 0 === $ position ) { array_unshift ( $ this -> items , $ item ) ; } else if ( null === $ position ) { $ this -> items [ ] = $ item ; } else if ( count ( $ this -> items ) <= $ position ) { $ this -> items [ ] = $ item ; } else { array_splice ( $ this -> items , $ position , 0 , [ $ item ] ) ; } $ this -> isUpdated = true ; return $ this ; }
Add item at the specified position

@param Item $item
@param int $position
If no position specified or int is higher to the higher bound,
append the item, for prepending set 0
Add item at the specified position