Skip to content

Commit

Permalink
Remove useless BaseCollection.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Aug 28, 2019
1 parent da1ab80 commit c8aca3c
Show file tree
Hide file tree
Showing 36 changed files with 222 additions and 198 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ the methods always return the same values for the same inputs.
| ------------- | --------------------- | -------------- |
| `all` | array | [All.php](./src/Operation/All.php)
| `append` | new Collection object | [Append.php](./src/Operation/Append.php)
| `apply` | self | [Apply.php](./src/Operation/Apply.php)
| `apply` | new Collection object | [Apply.php](./src/Operation/Apply.php)
| `chunk` | new Collection object | [Chunk.php](./src/Operation/Chunk.php)
| `collapse` | new Collection object | [Collapse.php](./src/Operation/Collapse.php)
| `combine` | new Collection object | [Combine.php](./src/Operation/Combine.php)
Expand Down
25 changes: 13 additions & 12 deletions spec/drupol/collection/CollectionSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace spec\drupol\collection;

use drupol\collection\BaseCollection;
use drupol\collection\Collection;
use drupol\collection\Contract\Operation;
use PhpSpec\ObjectBehavior;
Expand Down Expand Up @@ -33,36 +32,38 @@ public function it_can_append_items(): void

public function it_can_apply(): void
{
$input = \array_combine(\range('A', 'Z'), \range('A', 'Z'));

$this
->beConstructedThrough('with', [\range(1, 10)]);
->beConstructedThrough('with', [$input]);

$this
->apply(static function ($item) {
// do what you want here.

return true;
})
->shouldIterateAs(\range(1, 10));
->shouldIterateAs($input);

$this
->apply(static function ($item) {
// do what you want here.

return false;
})
->shouldIterateAs(\range(1, 10));
->shouldIterateAs($input);

$this
->apply(static function ($item): void {
$item %= 2;
->apply(static function ($item) {
return $item;
})
->shouldIterateAs([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
->shouldIterateAs($input);

$this
->apply(static function ($item) {
return false;
})
->shouldReturnAnInstanceOf(\drupol\collection\Contract\BaseCollection::class);
->shouldReturnAnInstanceOf(\drupol\collection\Contract\Collection::class);

$callback = static function (): void {
throw new \Exception('foo');
Expand All @@ -71,7 +72,7 @@ public function it_can_apply(): void
$this
->apply($callback)
->shouldThrow(\Exception::class)
->during('all', [$callback]);
->during('all');

$context = [];

Expand Down Expand Up @@ -172,21 +173,21 @@ public function it_can_be_constructed_with_a_closure(): void
yield from \range(1, 3);
}]);

$this->shouldImplement(BaseCollection::class);
$this->shouldImplement(Collection::class);
}

public function it_can_be_constructed_with_an_array(): void
{
$this
->beConstructedThrough('with', [['1', '2', '3']]);
$this->shouldImplement(BaseCollection::class);
$this->shouldImplement(Collection::class);
}

public function it_can_be_constructed_with_an_arrayObject(): void
{
$this
->beConstructedThrough('with', [new \ArrayObject([1, 2, 3])]);
$this->shouldImplement(BaseCollection::class);
$this->shouldImplement(Collection::class);
}

public function it_can_be_instantiated_with_withClosure(): void
Expand Down
67 changes: 0 additions & 67 deletions src/BaseCollection.php

This file was deleted.

Loading

0 comments on commit c8aca3c

Please sign in to comment.