| @@ 1747-1762 (lines=16) @@ | ||
| 1744 | * @return static |
|
| 1745 | * <p>(Immutable)</p> |
|
| 1746 | */ |
|
| 1747 | public function moveElementToFirstPlace($key): self |
|
| 1748 | { |
|
| 1749 | $array = $this->getArray(); |
|
| 1750 | ||
| 1751 | if ($this->offsetExists($key)) { |
|
| 1752 | $tmpValue = $this->get($key); |
|
| 1753 | unset($array[$key]); |
|
| 1754 | $array = [$key => $tmpValue] + $array; |
|
| 1755 | } |
|
| 1756 | ||
| 1757 | return static::create( |
|
| 1758 | $array, |
|
| 1759 | $this->iteratorClass, |
|
| 1760 | false |
|
| 1761 | ); |
|
| 1762 | } |
|
| 1763 | ||
| 1764 | /** |
|
| 1765 | * Move an array element to the last place. |
|
| @@ 1775-1790 (lines=16) @@ | ||
| 1772 | * @return static |
|
| 1773 | * <p>(Immutable)</p> |
|
| 1774 | */ |
|
| 1775 | public function moveElementToLastPlace($key): self |
|
| 1776 | { |
|
| 1777 | $array = $this->getArray(); |
|
| 1778 | ||
| 1779 | if ($this->offsetExists($key)) { |
|
| 1780 | $tmpValue = $this->get($key); |
|
| 1781 | unset($array[$key]); |
|
| 1782 | $array += [$key => $tmpValue]; |
|
| 1783 | } |
|
| 1784 | ||
| 1785 | return static::create( |
|
| 1786 | $array, |
|
| 1787 | $this->iteratorClass, |
|
| 1788 | false |
|
| 1789 | ); |
|
| 1790 | } |
|
| 1791 | ||
| 1792 | /** |
|
| 1793 | * Get the first key from the current array. |
|