public function set($name, $value)
    {
        $nameString = TypeHinter::to('USVString', $name, 0);
        $valueString = TypeHinter::to('USVString', $value, 1);
        $already = false;
        foreach ($this->list as $key => &$pair) {
            if ($pair[0] === $nameString) {
                if ($already) {
                    unset($this->list[$key]);
                } else {
                    $pair[1] = $valueString;
                    $already = true;
                }
            }
        }
        unset($pair);
        if ($already) {
            $this->list = array_values($this->list);
            array_splice($this->list, 0, count($this->list), $this->list);
        } else {
            $this->list[] = [$nameString, $valueString];
        }
        $this->update();
    }
public function set($name, $value)
    {
        $nameString = TypeHinter::to('USVString', $name, 0);
        $valueString = TypeHinter::to('USVString', $value, 1);
        $already = false;
        foreach ($this->list as $key => &$pair) {
            if ($pair[0] === $nameString) {
                if ($already) {
                    unset($this->list[$key]);
                } else {
                    $pair[1] = $valueString;
                    $already = true;
                }
            }
        }
        unset($pair);
        if ($already) {
            $this->list = array_values($this->list);
            array_splice($this->list, 0, count($this->list), $this->list);
        } else {
            $this->list[] = [$nameString, $valueString];
        }
        $this->update();
    }
public function set ( $ name , $ value ) { $ nameString = TypeHinter :: to ( 'USVString' , $ name , 0 ) ; $ valueString = TypeHinter :: to ( 'USVString' , $ value , 1 ) ; $ already = false ; foreach ( $ this -> list as $ key => & $ pair ) { if ( $ pair [ 0 ] === $ nameString ) { if ( $ already ) { unset ( $ this -> list [ $ key ] ) ; } else { $ pair [ 1 ] = $ valueString ; $ already = true ; } } } unset ( $ pair ) ; if ( $ already ) { $ this -> list = array_values ( $ this -> list ) ; array_splice ( $ this -> list , 0 , count ( $ this -> list ) , $ this -> list ) ; } else { $ this -> list [ ] = [ $ nameString , $ valueString ] ; } $ this -> update ( ) ; }
If there are any name-value pairs whose name is name, set the value of the first such name-value pair to value and remove the others.
Otherwise, append a new name-value pair whose name is name and value is value, to the list of name-value pairs.
@link https://url.spec.whatwg.org/#dom-urlsearchparams-setname-value URL Standard
@param string $name A USVString.
@param string $value A USVString.
If there are any name - value pairs whose name is name set the value of the first such name - value pair to value and remove the others . Otherwise append a new name - value pair whose name is name and value is value to the list of name - value pairs .