-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
59 changed files
with
602 additions
and
649 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
.DS_Store | ||
/.php_cs.cache | ||
/.phpunit.result.cache | ||
/composer.lock | ||
/vendor/ | ||
composer.lock |
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,25 @@ | ||
<?php | ||
|
||
$finder = PhpCsFixer\Finder::create() | ||
->in(__DIR__ . '/src') | ||
->in(__DIR__ . '/tests'); | ||
|
||
return PhpCsFixer\Config::create() | ||
->setRules([ | ||
'@PSR2' => true, | ||
'@Symfony' => true, | ||
'array_syntax' => ['syntax' => 'short'], | ||
'blank_line_before_statement' => false, | ||
'concat_space' => ['spacing' => 'one'], | ||
'function_declaration' => ['closure_function_spacing' => 'none'], | ||
'increment_style' => false, | ||
'phpdoc_align' => ['align' => 'left'], | ||
'phpdoc_separation' => false, | ||
'phpdoc_summary' => false, | ||
'phpdoc_to_comment' => false, | ||
'yoda_style' => false, | ||
]) | ||
->setFinder($finder); | ||
|
||
// __END__ | ||
// vim: filetype=php |
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,13 @@ | ||
<?xml version="1.0"?> | ||
<psalm | ||
totallyTyped="true" | ||
errorLevel="2" | ||
resolveFromConfigFile="true" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="https://getpsalm.org/schema/config" | ||
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" | ||
> | ||
<projectFiles> | ||
<directory name="src" /> | ||
</projectFiles> | ||
</psalm> |
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 |
---|---|---|
@@ -1,32 +1,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Emonkak\Random\Distribution; | ||
|
||
use Emonkak\Random\Engine\AbstractEngine; | ||
use Emonkak\Random\Engine\EngineInterface; | ||
|
||
abstract class AbstractDistribution | ||
/** | ||
* @template T | ||
* @implements DistributionInterface<T> | ||
*/ | ||
abstract class AbstractDistribution implements DistributionInterface | ||
{ | ||
/** | ||
* @param AbstractEngine $engine | ||
* @return mixed | ||
*/ | ||
public function __invoke(AbstractEngine $engine) | ||
{ | ||
return $this->generate($engine); | ||
} | ||
|
||
/** | ||
* @param AbstractEngine $engine | ||
* @return mixed | ||
*/ | ||
abstract public function generate(AbstractEngine $engine); | ||
|
||
/** | ||
* @param AbstractEngine $engine | ||
* @return \Iterator | ||
* {@inheritdoc} | ||
*/ | ||
public function iterate(AbstractEngine $engine) | ||
public function iterate(EngineInterface $engine): \Iterator | ||
{ | ||
return new DistributionIterator($this, $engine); | ||
while (true) { | ||
yield $this->generate($engine); | ||
} | ||
} | ||
} |
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,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Emonkak\Random\Distribution; | ||
|
||
use Emonkak\Random\Engine\EngineInterface; | ||
|
||
/** | ||
* @template T | ||
*/ | ||
interface DistributionInterface | ||
{ | ||
/** | ||
* @return T | ||
*/ | ||
public function generate(EngineInterface $engine); | ||
|
||
/** | ||
* @return \Iterator<T> | ||
*/ | ||
public function iterate(EngineInterface $engine): \Iterator; | ||
} |
Oops, something went wrong.