/** * @return \Icicle\Promise\PromiseInterface */ protected function getPromise() : PromiseInterface { if (null === $this->promise) { $promisor = $this->promisor; $this->promisor = null; try { $this->promise = Promise\resolve($promisor()); } catch (\Throwable $exception) { $this->promise = Promise\reject($exception); } } return $this->promise; }
/** * @coroutine * * @param float $time Time to sleep in seconds. * * @return \Generator * * @resolve float Actual time slept in seconds. */ function sleep(float $time) : \Generator { $start = (yield Promise\resolve(microtime(true))->delay($time)); return microtime(true) - $start; }
/** * @inheritdoc * * @param string $query * @param array $values * * @return PromiseInterface * * @throws InvalidArgumentException */ public function query($query, $values) { return Promise\resolve($this->connection->fetchAll($query, $values)); }