public function updateOrAdd(LineInterface $line)
    {
        $key = $line->key();

        $index = $this->search(function (LineInterface $line) use ($key) {
            return $line->key() == $key;
        });

        if ($index > -1) {
            $this->put($index, $line);
        } else {
            $this->add($line);
        }
    }
public function updateOrAdd(LineInterface $line)
    {
        $key = $line->key();

        $index = $this->search(function (LineInterface $line) use ($key) {
            return $line->key() == $key;
        });

        if ($index > -1) {
            $this->put($index, $line);
        } else {
            $this->add($line);
        }
    }
public function updateOrAdd ( LineInterface $ line ) { $ key = $ line -> key ( ) ; $ index = $ this -> search ( function ( LineInterface $ line ) use ( $ key ) { return $ line -> key ( ) == $ key ; } ) ; if ( $ index > - 1 ) { $ this -> put ( $ index , $ line ) ; } else { $ this -> add ( $ line ) ; } }
Update the line by key, or add it if there is no existing line for the same key.

@param LineInterface $line
Update the line by key or add it if there is no existing line for the same key .