diff --git a/src/ArrayClasses/IArrayClass.php b/src/ArrayClasses/IArrayClass.php index 2e698e6..d38b7a4 100644 --- a/src/ArrayClasses/IArrayClass.php +++ b/src/ArrayClasses/IArrayClass.php @@ -17,6 +17,14 @@ interface IArrayClass extends IImmutableArrayClass { * @return $this */ public function set ($cellName, $cellValue): self; + /** + * Add a cell (at the end) + * + * @param mixed $cellValue The cell new value + * + * @return $this + */ + public function push ($cellValue): self; /** * Remove a cell * diff --git a/src/ArrayClasses/TInternalArray.php b/src/ArrayClasses/TInternalArray.php index a3a4036..f136d31 100644 --- a/src/ArrayClasses/TInternalArray.php +++ b/src/ArrayClasses/TInternalArray.php @@ -6,24 +6,20 @@ use OutOfRangeException; trait TInternalArray { /** - * Create or replace a cell value - * - * @param mixed $cellName The cell name/offset - * @param mixed $cellValue The cell new value - * - * @return $this + * @inheritDoc */ public function set ($cellName, $cellValue): self { $this->array[$cellName] = $cellValue; return $this; } /** - * Remove a cell - * - * @param mixed $cellName The cell name/offset - * @param bool|null $throwsForNonExistentElement If set, temporarily override {@see ImmutableArrayClass::$throwsForNonExistentElement} - * - * @return $this + * @inheritDoc + */ + public function push ($cellValue): self { + return $this->set($this->count(), $cellValue); + } + /** + * @inheritDoc */ public function del ($cellName, ?bool $throwsForNonExistentElement = null): self { if ($throwsForNonExistentElement ?? $this->throwsForNonExistentElement() && !$this->has($cellName)) {