for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the Cubiche package.
*
* Copyright (c) Cubiche
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Cubiche\Core\Async\Promise;
/**
* Rejected Promise class.
* @author Karel Osorio Ramírez <[email protected]>
class RejectedPromise extends AbstractPromise
{
* @var mixed
protected $reason;
* @param mixed $reason
public function __construct($reason = null)
$this->reason = $reason;
}
* {@inheritdoc}
public function then(callable $onFulfilled = null, callable $onRejected = null, callable $onNotify = null)
if ($onRejected === null) {
return $this;
return new self($this->rejectActual($onRejected));
public function done(callable $onFulfilled = null, callable $onRejected = null, callable $onNotify = null)
if ($onRejected !== null) {
$onRejected($this->reason);
public function state()
return State::REJECTED();
* @param callable $onRejected
* @return mixed
private function rejectActual(callable $onRejected)
try {
} catch (\Exception $e) {
return $e;
return $this->reason;