@@ -74,7 +74,6 @@ This way you have the possibility to use them and extend it's behavior tailored
74
74
use DCSG\ImmutableCollections\ImmutableCollection;
75
75
76
76
final class MyStringCollection extends ImmutableCollection {
77
- ImmutableCollection
78
77
protected function validateItems(array $elements): void
79
78
{
80
79
foreach ($elements as $element) {
@@ -87,6 +86,7 @@ final class MyStringCollection extends ImmutableCollection {
87
86
88
87
$collection = MyStringCollection::create(['foo', 'bar']);
89
88
echo $collection->count(); // 2
89
+ $slicedCollection = $collection->slice(0, 1); // MyStringCollection { $elements=['foo']}
90
90
```
91
91
92
92
###### Creating a Typed Set Collection
@@ -97,7 +97,6 @@ echo $collection->count(); // 2
97
97
use DCSG\ImmutableCollections\SetImmutableCollection;
98
98
99
99
final class MyStringSetCollection extends SetImmutableCollection {
100
- ImmutableCollection
101
100
protected function validateItems(array $elements): void
102
101
{
103
102
foreach ($elements as $element) {
@@ -110,6 +109,7 @@ final class MyStringSetCollection extends SetImmutableCollection {
110
109
111
110
$collection = MyStringSetCollection::create(['foo', 'bar']);
112
111
echo $collection->count(); // 2
112
+ $slicedCollection = $collection->tail(); // MyStringSetCollection { $elements=['bar']}
113
113
114
114
$collection = MyStringSetCollection::create(['foo', 'bar', 'foo']); // Throws InvalidArgumentException
115
115
```
0 commit comments