File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree 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
5757``` php
5858<?php
5959
60- use DCSG\ImmutableCollections\Collection ;
60+ use DCSG\ImmutableCollections\ImmutableCollection ;
6161
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
6464 protected function validateItems(array $elements): void
6565 {
6666 foreach ($elements as $element) {
@@ -80,10 +80,10 @@ echo $collection->count(); // 2
8080``` php
8181<?php
8282
83- use DCSG\ImmutableCollections\SetCollection ;
83+ use DCSG\ImmutableCollections\SetImmutableCollection ;
8484
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
8787 protected function validateItems(array $elements): void
8888 {
8989 foreach ($elements as $element) {
Original file line number Diff line number Diff line change 33namespace Examples \DCSG \ImmutableCollections \CargoLegs ;
44
55use InvalidArgumentException ;
6- use DCSG \ImmutableCollections \Collection ;
6+ use DCSG \ImmutableCollections \ImmutableCollection ;
77
88/**
99 * @method Leg first()
1010 * @method Leg last()
1111 * @method Leg head()
1212 * @method Leg[] getIterator(): CollectionIterator
1313 */
14- final class Legs extends Collection
14+ final class Legs extends ImmutableCollection
1515{
1616 public function from (string $ location ): Legs
1717 {
Original file line number Diff line number Diff line change 33namespace Examples \DCSG \ImmutableCollections \Invoices ;
44
55use InvalidArgumentException ;
6- use DCSG \ImmutableCollections \Collection ;
6+ use DCSG \ImmutableCollections \ImmutableCollection ;
77
88/**
99 * @method InvoiceItem first()
1010 * @method InvoiceItem last()
1111 * @method InvoiceItem head()
1212 * @method InvoiceItem[] getIterator(): CollectionIterator
1313 */
14- final class InvoiceItems extends Collection
14+ final class InvoiceItems extends ImmutableCollection
1515{
1616 public function totalIncludingVAT (): float
1717 {
Original file line number Diff line number Diff line change 33namespace Examples \DCSG \ImmutableCollections \Invoices ;
44
55use InvalidArgumentException ;
6- use DCSG \ImmutableCollections \SetCollection ;
6+ use DCSG \ImmutableCollections \SetImmutableCollection ;
77
88/**
99 * @method Invoice first()
1010 * @method Invoice last()
1111 * @method Invoice head()
1212 * @method Invoice[] getIterator(): CollectionIterator
1313 */
14- final class Invoices extends SetCollection
14+ final class Invoices extends SetImmutableCollection
1515{
1616 public function totalExcludingVAT ()
1717 {
Original file line number Diff line number Diff line change 77/**
88 * @author Daniel Gomes <danielcesargomes@gmail.com>
99 */
10- abstract class Collection implements CollectionInterface
10+ abstract class ImmutableCollection implements CollectionInterface
1111{
1212 /** @var array */
1313 protected $ elements ;
Original file line number Diff line number Diff line change 77/**
88 * @author Daniel Gomes <danielcesargomes@gmail.com>
99 */
10- abstract class SetCollection extends Collection
10+ abstract class SetImmutableCollection extends ImmutableCollection
1111{
1212 protected function __construct (array $ elements )
1313 {
Original file line number Diff line number Diff line change 33namespace Tests \DCSG \ImmutableCollections ;
44
55use InvalidArgumentException ;
6- use DCSG \ImmutableCollections \Collection ;
6+ use DCSG \ImmutableCollections \ImmutableCollection ;
77use DCSG \ImmutableCollections \NotFoundException ;
88use PHPUnit \Framework \TestCase ;
99
@@ -197,7 +197,7 @@ public function testReduce()
197197
198198}
199199
200- final class StringCollection extends Collection
200+ final class StringCollection extends ImmutableCollection
201201{
202202 protected function validateItems (array $ elements ): void
203203 {
Original file line number Diff line number Diff line change 33namespace Tests \DCSG \ImmutableCollections ;
44
55use InvalidArgumentException ;
6- use DCSG \ImmutableCollections \SetCollection ;
6+ use DCSG \ImmutableCollections \SetImmutableCollection ;
77use PHPUnit \Framework \TestCase ;
88
99final class SetCollectionTest extends TestCase
@@ -20,7 +20,7 @@ public function testCreateWithValidElements(): void
2020 }
2121}
2222
23- final class StringSetCollection extends SetCollection
23+ final class StringSetCollection extends SetImmutableCollection
2424{
2525 protected function validateItems (array $ elements ): void
2626 {
You can’t perform that action at this time.
0 commit comments