| 1: | <?php declare(strict_types=1); |
| 2: | |
| 3: | namespace Salient\Contract\Core; |
| 4: | |
| 5: | /** |
| 6: | * @api |
| 7: | */ |
| 8: | interface Chainable |
| 9: | { |
| 10: | /** |
| 11: | * Move to the next method in the chain after applying a callback to the |
| 12: | * object |
| 13: | * |
| 14: | * @param callable(static): static $callback |
| 15: | * @return static |
| 16: | */ |
| 17: | public function apply(callable $callback); |
| 18: | |
| 19: | /** |
| 20: | * Move to the next method in the chain after applying a conditional |
| 21: | * callback to the object |
| 22: | * |
| 23: | * @param (callable(static): bool)|bool $condition |
| 24: | * @param (callable(static): static)|null $then Called if `$condition` |
| 25: | * resolves to `true`. |
| 26: | * @param (callable(static): static)|null $else Called if `$condition` |
| 27: | * resolves to `false`. |
| 28: | * @return static |
| 29: | */ |
| 30: | public function applyIf($condition, ?callable $then = null, ?callable $else = null); |
| 31: | |
| 32: | /** |
| 33: | * Move to the next method in the chain after applying a callback to the |
| 34: | * object for each item in an array or iterator |
| 35: | * |
| 36: | * @template TKey |
| 37: | * @template TValue |
| 38: | * |
| 39: | * @param iterable<TKey,TValue> $items |
| 40: | * @param callable(static, TValue, TKey): static $callback |
| 41: | * @return static |
| 42: | */ |
| 43: | public function applyForEach(iterable $items, callable $callback); |
| 44: | } |
| 45: |