/** * Push an item onto the beginning of the collection. * * @param mixed $value * @param mixed $key * * @return $this */ public function prepend($value, $key = null) { $this->items = Arr::prepend($this->items, $value, $key); return $this; }
public function testPrepend() { $array = Arr::prepend(['one', 'two', 'three', 'four'], 'zero'); $this->assertEquals(['zero', 'one', 'two', 'three', 'four'], $array); $array = Arr::prepend(['one' => 1, 'two' => 2], 0, 'zero'); $this->assertEquals(['zero' => 0, 'one' => 1, 'two' => 2], $array); }