diff --git a/CHANGELOG.md b/CHANGELOG.md index e31b6f3..524e3e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ - `Innmind\OperatingSystem\CurrentProcess` is now a final class - `Innmind\OperatingSystem\OperatingSystem::map()` callable must now return a `Config` - `Innmind\OperatingSystem\Config::of()` has been renamed `::new()` +- `Innmind\OperatingSystem\Filesystem::temporary()` now expects a `Innmind\Immutable\Sequence>` ### Fixed diff --git a/src/Filesystem.php b/src/Filesystem.php index 9b378ac..8426b11 100644 --- a/src/Filesystem.php +++ b/src/Filesystem.php @@ -117,7 +117,7 @@ public function watch(Path $path): Ping * can't be read twice. By using this temporary file content you can read it * multiple times. * - * @param Sequence> $chunks + * @param Sequence> $chunks * * @return Attempt */ @@ -133,7 +133,6 @@ public function temporary(Sequence $chunks): Attempt ->sink($tmp->push()->chunk(...)) ->attempt( static fn($push, $chunk) => $chunk - ->attempt(static fn() => new \RuntimeException('Failed to load chunk')) ->flatMap($push) ->map(static fn() => $push), ) diff --git a/tests/FilesystemTest.php b/tests/FilesystemTest.php index 20b4ae6..b852d3c 100644 --- a/tests/FilesystemTest.php +++ b/tests/FilesystemTest.php @@ -19,6 +19,7 @@ Sequence, Str, Maybe, + Attempt, }; use Innmind\BlackBox\{ PHPUnit\BlackBox, @@ -134,7 +135,7 @@ public function testCreateTemporaryFile() ->temporary( Sequence::of(...$chunks) ->map(Str::of(...)) - ->map(Maybe::just(...)), + ->map(Attempt::result(...)), ) ->match( static fn($content) => $content, @@ -166,6 +167,9 @@ public function testCreateTemporaryFileFailure() ->temporary( Sequence::of(...[...$leading, null, ...$trailing]) ->map(Maybe::of(...)) + ->map(static fn($chunk) => $chunk->attempt( + static fn() => new \RuntimeException, + )) ->map(static fn($chunk) => $chunk->map(Str::of(...))), ) ->match(