Skip to content
This repository was archived by the owner on Mar 14, 2024. It is now read-only.

Commit

Permalink
Merge pull request #305 from tighten/v9.14.1-changes
Browse files Browse the repository at this point in the history
v9.14.1 changes
  • Loading branch information
jamisonvalenta authored Jun 6, 2022
2 parents 1918b19 + 1ca85cf commit cd59145
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/Collect/Support/Arr.php
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,20 @@ public static function keyBy($array, $keyBy)
return Collection::make($array)->keyBy($keyBy)->all();
}

/**
* Prepend the key names of an associative array.
*
* @param array $array
* @param string $prependWith
* @return array
*/
public static function prependKeysWith($array, $prependWith)
{
return Collection::make($array)->mapWithKeys(function ($item, $key) use ($prependWith) {
return [$prependWith.$key => $item];
})->all();
}

/**
* Get a subset of the items from the given array.
*
Expand Down
21 changes: 21 additions & 0 deletions tests/Support/SupportArrTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1076,4 +1076,25 @@ public function testKeyBy()
'498' => ['id' => '498', 'data' => 'hgi'],
], Arr::keyBy($array, 'id'));
}

public function testPrependKeysWith()
{
$array = [
'id' => '123',
'data' => '456',
'list' => [1, 2, 3],
'meta' => [
'key' => 1,
],
];

$this->assertEquals([
'test.id' => '123',
'test.data' => '456',
'test.list' => [1, 2, 3],
'test.meta' => [
'key' => 1,
],
], Arr::prependKeysWith($array, 'test.'));
}
}
3 changes: 3 additions & 0 deletions tests/files/Support/Carbon.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@

use Carbon\Carbon as BaseCarbon;
use Carbon\CarbonImmutable as BaseCarbonImmutable;
use Tightenco\Collect\Support\Traits\Conditionable;

class Carbon extends BaseCarbon
{
use Conditionable;

/**
* {@inheritdoc}
*/
Expand Down
2 changes: 1 addition & 1 deletion upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ function getCurrentVersionFromGitHub()
echo Getting current version from $repository...

if [ -z "$requestedVersion" ]; then
collectionVersion=$(git ls-remote $repository --tags v9.13\* | grep tags/ | grep -v {} | cut -d \/ -f 3 | cut -d v -f 2 | grep -v RC | grep -vi beta | sort -t. -k 1,1n -k 2,2n -k 3,3n| tail -1)
collectionVersion=$(git ls-remote $repository --tags v9.14\* | grep tags/ | grep -v {} | cut -d \/ -f 3 | cut -d v -f 2 | grep -v RC | grep -vi beta | sort -t. -k 1,1n -k 2,2n -k 3,3n| tail -1)
else
collectionVersion=$requestedVersion
fi
Expand Down

0 comments on commit cd59145

Please sign in to comment.