Skip to content

Commit

Permalink
Let the BaseCollection implements the Runable interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Aug 28, 2019
1 parent 1e3b34b commit 64f3808
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
12 changes: 10 additions & 2 deletions src/BaseCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
namespace drupol\collection;

use drupol\collection\Contract\BaseCollection as BaseCollectionInterface;
use drupol\collection\Contract\Operation;
use drupol\collection\Iterator\ClosureIterator;
use drupol\collection\Operation\Run;

/**
* Class BaseCollection.
Expand Down Expand Up @@ -49,11 +51,17 @@ public function __construct($data = [])

/**
* {@inheritdoc}
*
* @throws \ReflectionException
*/
public function getIterator(): ClosureIterator
{
return new ClosureIterator($this->source);
}

/**
* {@inheritdoc}
*/
public function run(Operation ...$operations)
{
return (new Run(...$operations))->on($this);
}
}
9 changes: 0 additions & 9 deletions src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace drupol\collection;

use drupol\collection\Contract\Collection as CollectionInterface;
use drupol\collection\Contract\Operation;
use drupol\collection\Operation\All;
use drupol\collection\Operation\Append;
use drupol\collection\Operation\Apply;
Expand Down Expand Up @@ -295,14 +294,6 @@ public function reduce(callable $callback, $initial = null)
return $this->run(new Reduce($callback, $initial));
}

/**
* {@inheritdoc}
*/
public function run(Operation ...$operations)
{
return (new Run(...$operations))->on($this);
}

/**
* {@inheritdoc}
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Contract/BaseCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* Interface BaseCollection.
*/
interface BaseCollection extends \IteratorAggregate
interface BaseCollection extends \IteratorAggregate, Runable
{
/**
* {@inheritdoc}
Expand Down
1 change: 0 additions & 1 deletion src/Contract/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ interface Collection extends
Prependable,
Rebaseable,
Reduceable,
Runable,
Skipable,
Sliceable,
Sortable,
Expand Down

0 comments on commit 64f3808

Please sign in to comment.