Initial Commit

This commit is contained in:
David Stone
2024-11-30 18:24:12 -07:00
commit e8f7955c1c
5432 changed files with 1397750 additions and 0 deletions

View File

@ -0,0 +1,50 @@
<?php
namespace WP_Ultimo\Dependencies\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
}
}