Skip to content
This repository was archived by the owner on Feb 6, 2023. It is now read-only.

Commit 4011d1b

Browse files
Merge branch 'release/4.0.0'
2 parents 4f1895b + 5e9702e commit 4011d1b

File tree

9 files changed

+61
-15
lines changed

9 files changed

+61
-15
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ env:
1313
matrix:
1414
- LARAVEL_VERSION="5.8.*" COMPOSER_FLAGS="--prefer-lowest"
1515
- LARAVEL_VERSION="5.8.*" COMPOSER_FLAGS="--prefer-stable"
16+
- LARAVEL_VERSION="^6.0" COMPOSER_FLAGS="--prefer-lowest"
17+
- LARAVEL_VERSION="^6.0" COMPOSER_FLAGS="--prefer-stable"
1618
- LARAVEL_VERSION="dev-master" ORCHESTRA_VERSION="dev-master" COMPOSER_FLAGS="--prefer-lowest" MINIMUM_STABILITY="dev"
1719
- LARAVEL_VERSION="dev-master" ORCHESTRA_VERSION="dev-master" COMPOSER_FLAGS="--prefer-stable" MINIMUM_STABILITY="dev"
1820

@@ -34,6 +36,7 @@ install:
3436
- travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-dist
3537

3638
script:
39+
- vendor/bin/phpcs --runtime-set ignore_warnings_on_exit 1
3740
- vendor/bin/phpunit
3841

3942
branches:

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
66

77
## Unreleased
88

9+
## 4.0.0 (2019-08-14)
10+
11+
- Added support for Laravel 6.0
12+
913
## 3.0.0 (2019-02-27)
1014

1115
### Added

composer.json

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@
1919
}
2020
],
2121
"require": {
22-
"laravel/framework": "5.8.*",
23-
"php": "^7.2"
22+
"php": "^7.2",
23+
"laravel/framework": "5.8.*|^6.0"
2424
},
2525
"require-dev": {
2626
"kint-php/kint": "^3.1",
2727
"nesbot/carbon": "^1.25|^2.0",
28-
"orchestra/testbench": "3.8.*",
29-
"phpunit/phpunit": "^8.2"
28+
"orchestra/testbench": "3.8.*|^4.0",
29+
"phpunit/phpunit": "^8.3",
30+
"sebastiaanluca/php-codesniffer-ruleset": "^0.4.2"
3031
},
3132
"suggest": {
3233
"kint-php/kint": "A powerful and modern PHP debugging tool. Required for the debug collection macros.",
@@ -56,6 +57,9 @@
5657
}
5758
},
5859
"scripts": {
60+
"composer-validate": "@composer validate --no-check-all --strict --ansi",
61+
"codesniffer-check": "vendor/bin/phpcs --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1",
62+
"codesniffer-fix": "vendor/bin/phpcbf --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 || exit 0",
5963
"test": "vendor/bin/phpunit",
6064
"test-lowest": [
6165
"composer update --prefer-lowest --prefer-dist --no-interaction --ansi",
@@ -64,6 +68,13 @@
6468
"test-stable": [
6569
"composer update --prefer-stable --prefer-dist --no-interaction --ansi",
6670
"@test"
71+
],
72+
"check": [
73+
"@composer-validate",
74+
"@codesniffer-check",
75+
"@test"
6776
]
68-
}
77+
},
78+
"minimum-stability": "dev",
79+
"prefer-stable": true
6980
}

phpcs.xml.dist

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0"?>
2+
<ruleset>
3+
<arg name="basepath" value="."/>
4+
5+
<file>./src</file>
6+
<file>./tests</file>
7+
8+
<rule ref="./vendor/sebastiaanluca/php-codesniffer-ruleset/ruleset.xml"/>
9+
</ruleset>

src/Collections/CollectionMacrosServiceProvider.php

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace SebastiaanLuca\Helpers\Collections;
46

57
use Carbon\Carbon;
@@ -10,21 +12,25 @@ class CollectionMacrosServiceProvider extends ServiceProvider
1012
{
1113
/**
1214
* Boot the service provider.
15+
*
16+
* @return void
1317
*/
14-
public function boot()
18+
public function boot() : void
1519
{
16-
/**
20+
/*
1721
* Create Carbon instances from items in a collection.
1822
*/
23+
1924
Collection::macro('carbonize', function () {
2025
return collect($this->items)->map(function ($time) {
2126
return new Carbon($time);
2227
});
2328
});
2429

25-
/**
30+
/*
2631
* Reduce each collection item to the value found between a given start and end string.
2732
*/
33+
2834
Collection::macro('between', function ($start, $end = null) {
2935
$end = $end ?? $start;
3036

@@ -37,46 +43,51 @@ public function boot()
3743
});
3844
});
3945

40-
/**
46+
/*
4147
* Perform an operation on the collection's keys.
4248
*/
49+
4350
Collection::macro('transformKeys', function (callable $operation) {
4451
return collect($this->items)->mapWithKeys(function ($item, $key) use ($operation) {
4552
return [$operation($key) => $item];
4653
});
4754
});
4855

49-
/**
56+
/*
5057
* Transpose (flip) a collection matrix (array of arrays).
5158
*
5259
* @see https://adamwathan.me/2016/04/06/cleaning-up-form-input-with-transpose/
5360
*/
61+
5462
Collection::macro('transpose', function () {
5563
if ($this->isEmpty()) {
5664
return $this;
5765
}
58-
66+
5967
$items = array_map(function (...$items) {
6068
return $items;
6169
}, ...$this->values());
6270

6371
return new static($items);
6472
});
6573

66-
/**
74+
/*
6775
* Transpose (flip) a collection matrix (array of arrays) while keeping its columns and row headers intact.
6876
*
6977
* Please note that a row missing a column another row does have can only occur for one column. It cannot
7078
* parse more than one missing column.
7179
*/
72-
Collection::macro('transposeWithKeys', function (array $rows = null) {
80+
81+
Collection::macro('transposeWithKeys', function (?array $rows = null) {
7382
if ($this->isEmpty()) {
7483
return $this;
7584
}
76-
77-
$rows = $rows ?? $this->values()->reduce(function (array $rows, array $values) {
85+
86+
if ($rows === null) {
87+
$rows = $this->values()->reduce(function (array $rows, array $values) {
7888
return array_unique(array_merge($rows, array_keys($values)));
7989
}, []);
90+
}
8091

8192
$keys = $this->keys()->toArray();
8293

src/Methods/helpers.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
use Illuminate\Contracts\Auth\Authenticatable;
46

57
if (! function_exists('locale')) {

tests/TestCase.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace SebastiaanLuca\Helpers\Tests;
46

57
use Orchestra\Testbench\TestCase as OrchestraTestCase;

tests/Unit/Collections/CollectionMacrosTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace SebastiaanLuca\Helpers\Tests\Unit\Collections;
46

57
use Carbon\Carbon;

tests/Unit/Methods/GlobalHelpersTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace SebastiaanLuca\Helpers\Tests\Unit\Methods;
46

57
use Illuminate\Contracts\Auth\Authenticatable;

0 commit comments

Comments
 (0)