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