2018-01-13 17:36:01 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Amp\Internal;
|
|
|
|
|
|
|
|
use Amp\Promise;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Wraps a Promise instance that has public methods to resolve and fail the promise into an object that only allows
|
|
|
|
* access to the public API methods.
|
|
|
|
*/
|
2018-06-18 20:00:01 +02:00
|
|
|
class PrivatePromise implements Promise
|
|
|
|
{
|
2018-01-13 17:36:01 +01:00
|
|
|
/** @var \Amp\Promise */
|
|
|
|
private $promise;
|
|
|
|
|
2018-06-18 20:00:01 +02:00
|
|
|
public function __construct(Promise $promise)
|
|
|
|
{
|
2018-01-13 17:36:01 +01:00
|
|
|
$this->promise = $promise;
|
|
|
|
}
|
|
|
|
|
2018-06-18 20:00:01 +02:00
|
|
|
public function onResolve(callable $onResolved)
|
|
|
|
{
|
2018-01-13 17:36:01 +01:00
|
|
|
$this->promise->onResolve($onResolved);
|
|
|
|
}
|
|
|
|
}
|