Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop:
  add Set\Call
  • Loading branch information
Baptouuuu committed Jul 14, 2023
2 parents dafbb3c + 4c4c93a commit 7224869
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 5.1.0 - 2023-07-14

### Added

- `Innmind\BlackBox\Set\Call`

## 5.0.0 - 2023-05-29

### Added
Expand Down
21 changes: 21 additions & 0 deletions proofs/set/call.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
declare(strict_types = 1);

use Innmind\BlackBox\{
Set,
Random,
};

return static function() {
yield test(
'Set\Call always return a new value',
static function($assert) {
$set = Set\Call::of(static fn() => new \stdClass);

$assert
->expected($set->values(Random::default)->current()->unwrap())
->not()
->same($set->values(Random::default)->current()->unwrap());
},
);
};
25 changes: 25 additions & 0 deletions src/Set/Call.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
declare(strict_types = 1);

namespace Innmind\BlackBox\Set;

use Innmind\BlackBox\Set;

final class Call
{
/**
* @template T
*
* @param callable(): T $call
*
* @return Set<T>
*/
public static function of(callable $call): Set
{
return FromGenerator::of(static function() use ($call) {
while (true) {
yield $call();
}
});
}
}

0 comments on commit 7224869

Please sign in to comment.