Skip to content

Commit 0f5337f

Browse files
committed
specify method. rename conjoin
1 parent 8d0a9b7 commit 0f5337f

File tree

3 files changed

+26
-26
lines changed

3 files changed

+26
-26
lines changed

src/Illuminate/Support/Collection.php

+17-17
Original file line numberDiff line numberDiff line change
@@ -181,23 +181,6 @@ public function collapse()
181181
return new static(Arr::collapse($this->items));
182182
}
183183

184-
/**
185-
* Conjoin all values of a collection with those of another, regardless of keys.
186-
*
187-
* @param \Traversable $source
188-
* @return self
189-
*/
190-
public function conjoin($source)
191-
{
192-
$joinedCollection = new static($this);
193-
194-
foreach ($source as $item) {
195-
$joinedCollection->push($item);
196-
}
197-
198-
return $joinedCollection;
199-
}
200-
201184
/**
202185
* Determine if an item exists in the collection.
203186
*
@@ -1008,6 +991,23 @@ public function push($value)
1008991
return $this;
1009992
}
1010993

994+
/**
995+
* Push all of the given items onto the collection.
996+
*
997+
* @param \Traversable $source
998+
* @return self
999+
*/
1000+
public function concat($source)
1001+
{
1002+
$result = new static($this);
1003+
1004+
foreach ($source as $item) {
1005+
$result->push($item);
1006+
}
1007+
1008+
return $result;
1009+
}
1010+
10111011
/**
10121012
* Get and remove an item from the collection.
10131013
*

tests/Database/DatabaseEloquentHasOneTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function testHasOneWithArrayDefault()
7676
public function testMakeMethodDoesNotSaveNewModel()
7777
{
7878
$relation = $this->getRelation();
79-
$instance = $this->getMockBuilder('Illuminate\Database\Eloquent\Model')->setMethods(['newInstance', 'setAttribute'])->getMock();
79+
$instance = $this->getMockBuilder('Illuminate\Database\Eloquent\Model')->setMethods(['save', 'newInstance', 'setAttribute'])->getMock();
8080
$relation->getRelated()->shouldReceive('newInstance')->with(['name' => 'taylor'])->andReturn($instance);
8181
$instance->expects($this->once())->method('setAttribute')->with('foreign_key', 1);
8282
$instance->expects($this->never())->method('save');

tests/Support/SupportCollectionTest.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -1722,7 +1722,7 @@ public function testCombineWithCollection()
17221722
$this->assertSame($expected, $actual);
17231723
}
17241724

1725-
public function testConJoinWithArray()
1725+
public function testConcatWithArray()
17261726
{
17271727
$expected = [
17281728
0 => 4,
@@ -1740,14 +1740,14 @@ public function testConJoinWithArray()
17401740
];
17411741

17421742
$collection = new Collection([4, 5, 6]);
1743-
$collection = $collection->conjoin(['a', 'b', 'c']);
1744-
$collection = $collection->conjoin(['who' => 'Jonny', 'preposition' => 'from', 'where' => 'Laroe']);
1745-
$actual = $collection->conjoin(['who' => 'Jonny', 'preposition' => 'from', 'where' => 'Laroe'])->toArray();
1743+
$collection = $collection->concat(['a', 'b', 'c']);
1744+
$collection = $collection->concat(['who' => 'Jonny', 'preposition' => 'from', 'where' => 'Laroe']);
1745+
$actual = $collection->concat(['who' => 'Jonny', 'preposition' => 'from', 'where' => 'Laroe'])->toArray();
17461746

17471747
$this->assertSame($expected, $actual);
17481748
}
17491749

1750-
public function testConJoinWithCollection()
1750+
public function testConcatWithCollection()
17511751
{
17521752
$expected = [
17531753
0 => 4,
@@ -1767,9 +1767,9 @@ public function testConJoinWithCollection()
17671767
$firstCollection = new Collection([4, 5, 6]);
17681768
$secondCollection = new Collection(['a', 'b', 'c']);
17691769
$thirdCollection = new Collection(['who' => 'Jonny', 'preposition' => 'from', 'where' => 'Laroe']);
1770-
$firstCollection = $firstCollection->conjoin($secondCollection);
1771-
$firstCollection = $firstCollection->conjoin($thirdCollection);
1772-
$actual = $firstCollection->conjoin($thirdCollection)->toArray();
1770+
$firstCollection = $firstCollection->concat($secondCollection);
1771+
$firstCollection = $firstCollection->concat($thirdCollection);
1772+
$actual = $firstCollection->concat($thirdCollection)->toArray();
17731773

17741774
$this->assertSame($expected, $actual);
17751775
}

0 commit comments

Comments
 (0)