Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3declare(strict_types=1);
4
5/**
6 * This file is part of fast-forward/defer.
7 *
8 * This source file is subject to the license bundled
9 * with this source code in the file LICENSE.
10 *
11 * @copyright Copyright (c) 2026 Felipe SayĆ£o Lobato Abreu <github@mentordosnerds.com>
12 * @license   https://opensource.org/licenses/MIT MIT License
13 *
14 * @see       https://github.com/php-fast-forward/defer
15 * @see       https://github.com/php-fast-forward
16 * @see       https://datatracker.ietf.org/doc/html/rfc2119
17 */
18
19namespace FastForward\Defer;
20
21use Countable;
22
23/**
24 * This interface MUST be implemented by any class that manages deferred callbacks.
25 * Implementations SHALL provide mechanisms to register, execute, and check the presence of callbacks.
26 * All documentation MUST be in English and use RFC 2119 terminology.
27 */
28interface DeferInterface extends Countable
29{
30    /**
31     * Registers a callback to be executed later.
32     *
33     * This method MUST add the callback to the stack. It MAY be called multiple times.
34     *
35     * @param callable $callback the callback to register
36     * @param mixed ...$arguments Arguments for the callback.
37     *
38     * @return void
39     */
40    public function __invoke(callable $callback, mixed ...$arguments): void;
41
42    /**
43     * Registers a callback to be executed later.
44     *
45     * This method MUST add the callback to the stack. It MAY be called multiple times.
46     *
47     * @param callable $callback the callback to register
48     * @param mixed ...$args Arguments for the callback.
49     *
50     * @return void
51     */
52    public function defer(callable $callback, mixed ...$args): void;
53
54    /**
55     * Determines if there are no registered callbacks.
56     *
57     * This method MUST return true if no callbacks are registered; otherwise, it MUST return false.
58     *
59     * @return bool true if no callbacks are registered; otherwise, false
60     */
61    public function isEmpty(): bool;
62}