Skip to content

Commit

Permalink
flow or inherent flaw?
Browse files Browse the repository at this point in the history
  • Loading branch information
dakujem committed Aug 28, 2024
1 parent 8857fd5 commit 18ae742
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/Flow.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

namespace Dakujem\Toru;

/**
* Flow
*
* @author Andrej Rypak <xrypak@gmail.com>
*/
final class Flow
{
public function __construct(
private readonly mixed $current,
) {
}

public static function with(mixed $current): self
{
return new self($current);
}

public function do(callable $fn): self
{
return new self(
$fn($this->current),
);
}

public function result(): mixed
{
return $this->current;
}
}

0 comments on commit 18ae742

Please sign in to comment.