From 270eeb8387d4f1c341feec9ad795d5a00cbc7d30 Mon Sep 17 00:00:00 2001 From: freek Date: Tue, 19 Mar 2019 19:07:58 +0100 Subject: [PATCH] wip --- CHANGELOG.md | 5 +++++ README.md | 16 ---------------- composer.json | 2 +- src/Macros/Join.php | 34 ---------------------------------- tests/Macros/JoinTest.php | 23 ----------------------- 5 files changed, 6 insertions(+), 74 deletions(-) delete mode 100644 src/Macros/Join.php delete mode 100644 tests/Macros/JoinTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index e1f6b53..ccb4756 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to `laravel-collection-macros` will be documented in this file +## 5.0.2 - 2019-0319 + +- require laravel 5.8.4 +- remove `join` method as the same implementation has been added to Laravel + ## 5.0.1 - 2019-03-07 - fix `paginate` for pages other than 1 diff --git a/README.md b/README.md index e5a6c59..ef21dda 100644 --- a/README.md +++ b/README.md @@ -374,22 +374,6 @@ collect([1, 2, 3])->ifEmpty(function(Collection $collection) { // non-empty coll }); ``` -### `join` - -Join all items from the collection using a string. The final item can be glued with another string. - -```php -collect(['a', 'b', 'c']))->join(', ')); // returns 'a, b, c' - -collect(['a', 'b', 'c']))->join(', ', ' and ')); // returns 'a, b and c' - -collect(['a', 'b']))->join(', ', ' and ')); // returns 'a and b' - -collect(['a']))->join(', ', ' and ')); // returns 'a' - -collect([]))->join(', ', ' and ')); // returns '' -``` - ### `none` Checks whether a collection doesn't contain any occurrences of a given item, key-value pair, or passing truth test. The function accepts the same parameters as the `contains` collection method. diff --git a/composer.json b/composer.json index 3f9b13e..634cb36 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ ], "require": { "php": "^7.2", - "laravel/framework": "~5.8.0" + "laravel/framework": "~5.8.4" }, "require-dev": { "amphp/parallel": "^0.2.0", diff --git a/src/Macros/Join.php b/src/Macros/Join.php deleted file mode 100644 index d1f8b49..0000000 --- a/src/Macros/Join.php +++ /dev/null @@ -1,34 +0,0 @@ -implode($glue); - } - - if ($this->count() === 0) { - return ''; - } - - if ($this->count() === 1) { - return $this->last(); - } - - $collection = new Collection($this->items); - - $finalItem = $collection->pop(); - - return $collection->implode($glue).$finalGlue.$finalItem; - }; - } -} diff --git a/tests/Macros/JoinTest.php b/tests/Macros/JoinTest.php deleted file mode 100644 index 5c7a870..0000000 --- a/tests/Macros/JoinTest.php +++ /dev/null @@ -1,23 +0,0 @@ -assertEquals('a, b, c', (new Collection(['a', 'b', 'c']))->join(', ')); - - $this->assertEquals('a, b and c', (new Collection(['a', 'b', 'c']))->join(', ', ' and ')); - - $this->assertEquals('a and b', (new Collection(['a', 'b']))->join(', ', ' and ')); - - $this->assertEquals('a', (new Collection(['a']))->join(', ', ' and ')); - - $this->assertEquals('', (new Collection([]))->join(', ', ' and ')); - } -}