-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from drupol/interfaces-cleanup
Interfaces cleanup
- Loading branch information
Showing
25 changed files
with
192 additions
and
313 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace drupol\phpermutations; | ||
|
||
interface GeneratorInterface | ||
{ | ||
/** | ||
* Get the generator. | ||
* | ||
* @return \Generator | ||
* The generator | ||
*/ | ||
public function generator(); | ||
|
||
/** | ||
* Convert the generator into an array. | ||
* | ||
* @return array | ||
*/ | ||
public function toArray(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
namespace drupol\phpermutations\Generators; | ||
|
||
use drupol\phpermutations\GeneratorInterface; | ||
use drupol\phpermutations\Iterators\Combinations as CombinationsIterator; | ||
|
||
/** | ||
|
@@ -10,24 +11,18 @@ | |
* | ||
* @author Mark Wilson <[email protected]> | ||
*/ | ||
class Combinations extends CombinationsIterator | ||
class Combinations extends CombinationsIterator implements GeneratorInterface | ||
{ | ||
/** | ||
* Alias of the get() method. | ||
* | ||
* @return \Generator | ||
* The prime generator | ||
* {@inheritdoc} | ||
*/ | ||
public function generator() | ||
{ | ||
return $this->get($this->getDataset(), $this->getLength()); | ||
} | ||
|
||
/** | ||
* Convert the generator into an array. | ||
* | ||
* @return array | ||
* The elements | ||
* {@inheritdoc} | ||
*/ | ||
public function toArray() | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace drupol\phpermutations\Generators; | ||
|
||
use drupol\phpermutations\GeneratorInterface; | ||
use drupol\phpermutations\Iterators\NGrams as NGramsIterator; | ||
|
||
/** | ||
* Class NGrams. | ||
*/ | ||
class NGrams extends NGramsIterator implements GeneratorInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function generator() | ||
{ | ||
return $this->get(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function toArray() | ||
{ | ||
return []; | ||
} | ||
|
||
/** | ||
* Get the generator. | ||
* | ||
* @codingStandardsIgnoreStart | ||
* | ||
* @return \Generator | ||
* The generator | ||
* @codingStandardsIgnoreEnd | ||
*/ | ||
protected function get() | ||
{ | ||
while (true) { | ||
$this->next(); | ||
yield $this->current(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace drupol\phpermutations; | ||
|
||
interface IteratorInterface extends \Iterator | ||
{ | ||
} |
Oops, something went wrong.