From 6a7bdb5305343d7b0245548626868ceb780ff611 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Planchat?= Date: Thu, 24 Jun 2021 22:46:26 +0200 Subject: [PATCH] Updated dependencies --- src/FailedPromise.php | 22 +++++++++------------- src/Promise.php | 22 +++++++++++----------- src/SucceededPromise.php | 20 ++++++++------------ 3 files changed, 28 insertions(+), 36 deletions(-) diff --git a/src/FailedPromise.php b/src/FailedPromise.php index a299364..969734a 100644 --- a/src/FailedPromise.php +++ b/src/FailedPromise.php @@ -2,36 +2,32 @@ namespace Kiboko\Component\Promise; -use Kiboko\Component\Promise\Resolution\Failure; -use Kiboko\Contract\Promise\DeferredInterface; -use Kiboko\Contract\Promise\PromiseInterface; -use Kiboko\Contract\Promise\Resolution\FailureInterface; -use Kiboko\Contract\Promise\Resolution\ResolutionInterface; +use Kiboko\Contract\Promise as Contract; /** * @api */ -final class FailedPromise implements PromiseInterface +final class FailedPromise implements Contract\PromiseInterface { - private FailureInterface $resolution; + private Contract\Resolution\FailureInterface $resolution; public function __construct(\Throwable $exception) { - $this->resolution = new Failure($exception); + $this->resolution = new Resolution\Failure($exception); } - public function then(callable $callback): PromiseInterface + public function then(callable $callback): Contract\PromiseInterface { return $this; } - public function failure(callable $callback): PromiseInterface + public function failure(callable $callback): Contract\PromiseInterface { - $callback($this->resolution->error()); + $this->resolution->apply($callback); return $this; } - public function defer(): DeferredInterface + public function defer(): Contract\DeferredInterface { return new Deferred($this); } @@ -51,7 +47,7 @@ public function isFailure(): bool return true; } - public function resolution(): ResolutionInterface + public function resolution(): Contract\Resolution\ResolutionInterface { return $this->resolution; } diff --git a/src/Promise.php b/src/Promise.php index 9486a15..c21720d 100644 --- a/src/Promise.php +++ b/src/Promise.php @@ -2,18 +2,18 @@ namespace Kiboko\Component\Promise; -use Kiboko\Component\ETL\Promise\Resolution; +use Kiboko\Contract\Promise as Contract; /** * @api */ -final class Promise implements ResolvablePromiseInterface +final class Promise implements Contract\ResolvablePromiseInterface { /** @var callable */ private $successCallbacks; /** @var callable */ private $failureCallbacks; - private Resolution\ResolutionInterface $resolution; + private Contract\Resolution\ResolutionInterface $resolution; public function __construct() { @@ -22,14 +22,14 @@ public function __construct() $this->resolution = new Resolution\Pending(); } - public function defer(): DeferredInterface + public function defer(): Contract\DeferredInterface { return new Deferred($this); } - public function then(callable $callback): PromiseInterface + public function then(callable $callback): Contract\PromiseInterface { - if ($this->resolution instanceof SuccessInterface) { + if ($this->resolution instanceof Contract\Resolution\SuccessInterface) { $this->resolution->apply($callback); } @@ -38,9 +38,9 @@ public function then(callable $callback): PromiseInterface return $this; } - public function failure(callable $callback): PromiseInterface + public function failure(callable $callback): Contract\PromiseInterface { - if ($this->resolution instanceof FailureInterface) { + if ($this->resolution instanceof Contract\Resolution\FailureInterface) { $this->resolution->apply($callback); } @@ -88,15 +88,15 @@ public function isResolved(): bool public function isSuccess(): bool { - return $this->resolution instanceof Resolution\SuccessInterface; + return $this->resolution instanceof Contract\Resolution\SuccessInterface; } public function isFailure(): bool { - return $this->resolution instanceof Resolution\FailureInterface; + return $this->resolution instanceof Contract\Resolution\FailureInterface; } - public function resolution(): Resolution\ResolutionInterface + public function resolution(): Contract\Resolution\ResolutionInterface { return $this->resolution; } diff --git a/src/SucceededPromise.php b/src/SucceededPromise.php index 15f635a..5c2ca41 100644 --- a/src/SucceededPromise.php +++ b/src/SucceededPromise.php @@ -2,36 +2,32 @@ namespace Kiboko\Component\Promise; -use Kiboko\Component\Promise\Resolution; -use Kiboko\Contract\Promise\DeferredInterface; -use Kiboko\Contract\Promise\PromiseInterface; -use Kiboko\Contract\Promise\Resolution\ResolutionInterface; -use Kiboko\Contract\Promise\Resolution\SuccessInterface; +use Kiboko\Contract\Promise as Contract; /** * @api */ -final class SucceededPromise implements PromiseInterface +final class SucceededPromise implements Contract\PromiseInterface { - private SuccessInterface $resolution; + private Contract\Resolution\SuccessInterface $resolution; public function __construct($value) { $this->resolution = new Resolution\Success($value); } - public function then(callable $callback): PromiseInterface + public function then(callable $callback): Contract\PromiseInterface { - $callback($this->resolution->value()); + $this->resolution->apply($callback); return $this; } - public function failure(callable $callback): PromiseInterface + public function failure(callable $callback): Contract\PromiseInterface { return $this; } - public function defer(): DeferredInterface + public function defer(): Contract\DeferredInterface { return new Deferred($this); } @@ -51,7 +47,7 @@ public function isFailure(): bool return false; } - public function resolution(): ResolutionInterface + public function resolution(): Contract\Resolution\ResolutionInterface { return $this->resolution; }