public function swap($swapA, $swapB): self
    {
        $array = $this->getArray();

        list($array[$swapA], $array[$swapB]) = [$array[$swapB], $array[$swapA]];

        return static::create(
            $array,
            $this->iteratorClass,
            false
        );
    }
public function swap($swapA, $swapB): self
    {
        $array = $this->getArray();

        list($array[$swapA], $array[$swapB]) = [$array[$swapB], $array[$swapA]];

        return static::create(
            $array,
            $this->iteratorClass,
            false
        );
    }
public function swap ( $ swapA , $ swapB ) : self { $ array = $ this -> getArray ( ) ; list ( $ array [ $ swapA ] , $ array [ $ swapB ] ) = [ $ array [ $ swapB ] , $ array [ $ swapA ] ] ; return static :: create ( $ array , $ this -> iteratorClass , false ) ; }
Swap two values between positions by key.

@param int|string $swapA <p>a key in the array</p>
@param int|string $swapB <p>a key in the array</p>

@return static
<p>(Immutable)</p>
Swap two values between positions by key .