File tree Expand file tree Collapse file tree 8 files changed +18
-18
lines changed Expand file tree Collapse file tree 8 files changed +18
-18
lines changed Original file line number Diff line number Diff line change @@ -57,10 +57,10 @@ This way you have the possibility to use them and extend it's behavior tailored
57
57
``` php
58
58
<?php
59
59
60
- use DCSG\ImmutableCollections\Collection ;
60
+ use DCSG\ImmutableCollections\ImmutableCollection ;
61
61
62
- final class MyStringCollection extends Collection {
63
- // We have to override the `validateItems` in order to ensure the right Type for the Collection.
62
+ final class MyStringCollection extends ImmutableCollection {
63
+ ImmutableCollection
64
64
protected function validateItems(array $elements): void
65
65
{
66
66
foreach ($elements as $element) {
@@ -80,10 +80,10 @@ echo $collection->count(); // 2
80
80
``` php
81
81
<?php
82
82
83
- use DCSG\ImmutableCollections\SetCollection ;
83
+ use DCSG\ImmutableCollections\SetImmutableCollection ;
84
84
85
- final class MyStringSetCollection extends SetCollection {
86
- // We have to override the `validateItems` in order to ensure the right Type for the Collection.
85
+ final class MyStringSetCollection extends SetImmutableCollection {
86
+ ImmutableCollection
87
87
protected function validateItems(array $elements): void
88
88
{
89
89
foreach ($elements as $element) {
Original file line number Diff line number Diff line change 3
3
namespace Examples \DCSG \ImmutableCollections \CargoLegs ;
4
4
5
5
use InvalidArgumentException ;
6
- use DCSG \ImmutableCollections \Collection ;
6
+ use DCSG \ImmutableCollections \ImmutableCollection ;
7
7
8
8
/**
9
9
* @method Leg first()
10
10
* @method Leg last()
11
11
* @method Leg head()
12
12
* @method Leg[] getIterator(): CollectionIterator
13
13
*/
14
- final class Legs extends Collection
14
+ final class Legs extends ImmutableCollection
15
15
{
16
16
public function from (string $ location ): Legs
17
17
{
Original file line number Diff line number Diff line change 3
3
namespace Examples \DCSG \ImmutableCollections \Invoices ;
4
4
5
5
use InvalidArgumentException ;
6
- use DCSG \ImmutableCollections \Collection ;
6
+ use DCSG \ImmutableCollections \ImmutableCollection ;
7
7
8
8
/**
9
9
* @method InvoiceItem first()
10
10
* @method InvoiceItem last()
11
11
* @method InvoiceItem head()
12
12
* @method InvoiceItem[] getIterator(): CollectionIterator
13
13
*/
14
- final class InvoiceItems extends Collection
14
+ final class InvoiceItems extends ImmutableCollection
15
15
{
16
16
public function totalIncludingVAT (): float
17
17
{
Original file line number Diff line number Diff line change 3
3
namespace Examples \DCSG \ImmutableCollections \Invoices ;
4
4
5
5
use InvalidArgumentException ;
6
- use DCSG \ImmutableCollections \SetCollection ;
6
+ use DCSG \ImmutableCollections \SetImmutableCollection ;
7
7
8
8
/**
9
9
* @method Invoice first()
10
10
* @method Invoice last()
11
11
* @method Invoice head()
12
12
* @method Invoice[] getIterator(): CollectionIterator
13
13
*/
14
- final class Invoices extends SetCollection
14
+ final class Invoices extends SetImmutableCollection
15
15
{
16
16
public function totalExcludingVAT ()
17
17
{
Original file line number Diff line number Diff line change 7
7
/**
8
8
* @author Daniel Gomes <[email protected] >
9
9
*/
10
- abstract class Collection implements CollectionInterface
10
+ abstract class ImmutableCollection implements CollectionInterface
11
11
{
12
12
/** @var array */
13
13
protected $ elements ;
Original file line number Diff line number Diff line change 7
7
/**
8
8
* @author Daniel Gomes <[email protected] >
9
9
*/
10
- abstract class SetCollection extends Collection
10
+ abstract class SetImmutableCollection extends ImmutableCollection
11
11
{
12
12
protected function __construct (array $ elements )
13
13
{
Original file line number Diff line number Diff line change 3
3
namespace Tests \DCSG \ImmutableCollections ;
4
4
5
5
use InvalidArgumentException ;
6
- use DCSG \ImmutableCollections \Collection ;
6
+ use DCSG \ImmutableCollections \ImmutableCollection ;
7
7
use DCSG \ImmutableCollections \NotFoundException ;
8
8
use PHPUnit \Framework \TestCase ;
9
9
@@ -197,7 +197,7 @@ public function testReduce()
197
197
198
198
}
199
199
200
- final class StringCollection extends Collection
200
+ final class StringCollection extends ImmutableCollection
201
201
{
202
202
protected function validateItems (array $ elements ): void
203
203
{
Original file line number Diff line number Diff line change 3
3
namespace Tests \DCSG \ImmutableCollections ;
4
4
5
5
use InvalidArgumentException ;
6
- use DCSG \ImmutableCollections \SetCollection ;
6
+ use DCSG \ImmutableCollections \SetImmutableCollection ;
7
7
use PHPUnit \Framework \TestCase ;
8
8
9
9
final class SetCollectionTest extends TestCase
@@ -20,7 +20,7 @@ public function testCreateWithValidElements(): void
20
20
}
21
21
}
22
22
23
- final class StringSetCollection extends SetCollection
23
+ final class StringSetCollection extends SetImmutableCollection
24
24
{
25
25
protected function validateItems (array $ elements ): void
26
26
{
You can’t perform that action at this time.
0 commit comments