ok

Mini Shell

Direktori : /home2/selectio/www/fms-worksuite/vendor/amphp/amp/lib/
Upload File :
Current File : /home2/selectio/www/fms-worksuite/vendor/amphp/amp/lib/NullCancellationToken.php

<?php

namespace Amp;

/**
 * A NullCancellationToken can be used to avoid conditionals to check whether a token has been provided.
 *
 * Instead of writing
 *
 * ```php
 * if ($token) {
 *     $token->throwIfRequested();
 * }
 * ```
 *
 * potentially multiple times, it allows writing
 *
 * ```php
 * $token = $token ?? new NullCancellationToken;
 *
 * // ...
 *
 * $token->throwIfRequested();
 * ```
 *
 * instead.
 */
final class NullCancellationToken implements CancellationToken
{
    /** @inheritdoc */
    public function subscribe(callable $callback): string
    {
        return "null-token";
    }

    /** @inheritdoc */
    public function unsubscribe(string $id)
    {
        // nothing to do
    }

    /** @inheritdoc */
    public function isRequested(): bool
    {
        return false;
    }

    /** @inheritdoc */
    public function throwIfRequested()
    {
        // nothing to do
    }
}

Zerion Mini Shell 1.0