本文整理汇总了PHP中reject函数的典型用法代码示例。如果您正苦于以下问题:PHP reject函数的具体用法?PHP reject怎么用?PHP reject使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了reject函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reject
private function reject($reason = null)
{
if (null !== $this->result) {
return;
}
$this->settle(reject($reason));
}
示例2: checkQuotaStatus
public function checkQuotaStatus()
{
if ($this->user->isLimited() && $this->user->limitExpired() && !$this->user->aq_access) {
reject("Time/Data Limit Exceeded.");
}
return $this;
}
示例3: shouldRejectARejectedPromise
/** @test */
public function shouldRejectARejectedPromise()
{
$expected = 123;
$resolved = new RejectedPromise($expected);
$mock = $this->createCallableMock();
$mock->expects($this->once())->method('__invoke')->with($this->identicalTo($expected));
reject($resolved)->then($this->expectCallableNever(), $mock);
}
示例4: getAwaitable
/**
* @return \Icicle\Awaitable\Awaitable
*/
protected function getAwaitable()
{
if (null === $this->promise) {
$promisor = $this->promisor;
$this->promisor = null;
try {
$this->promise = resolve($promisor());
} catch (\Throwable $exception) {
$this->promise = reject($exception);
}
}
return $this->promise;
}
示例5: some
function some(array $promisesOrValues, $howMany)
{
if ($howMany < 1) {
return resolve([]);
}
$len = count($promisesOrValues);
if ($len < $howMany) {
return reject(new Exception\LengthException(sprintf('Input array must contain at least %d item%s but contains only %s item%s.', $howMany, 1 === $howMany ? '' : 's', $len, 1 === $len ? '' : 's')));
}
$cancellationQueue = new CancellationQueue();
return new Promise(function ($resolve, $reject) use($len, $promisesOrValues, $howMany, $cancellationQueue) {
$toResolve = $howMany;
$toReject = $len - $toResolve + 1;
$values = [];
$reasons = [];
foreach ($promisesOrValues as $i => $promiseOrValue) {
$fulfiller = function ($val) use($i, &$values, &$toResolve, $toReject, $resolve) {
if ($toResolve < 1 || $toReject < 1) {
return;
}
$values[$i] = $val;
if (0 === --$toResolve) {
$resolve($values);
}
};
$rejecter = function ($reason) use($i, &$reasons, &$toReject, $toResolve, $reject) {
if ($toResolve < 1 || $toReject < 1) {
return;
}
$reasons[$i] = $reason;
if (0 === --$toReject) {
$reject($reasons);
}
};
$cancellationQueue->enqueue($promiseOrValue);
resolve($promiseOrValue)->done($fulfiller, $rejecter);
}
}, $cancellationQueue);
}
示例6: fetchAccount
public function fetchAccount($acctsessionid = NULL, $acctuniqueid = NULL)
{
$q = Capsule::table('user_accounts as u')->select('u.uname', 'u.status', 'u.clear_pword', 'u.id', 'r.time_limit', 'r.data_limit', 'r.expiration', 'r.aq_invocked', 'v.plan_type', 'v.policy_type', 'v.policy_id', 'v.sim_sessions', 'v.interim_updates', 'l.limit_type', 'l.aq_access', 'l.aq_policy')->leftJoin('user_recharges as r', 'r.user_id', '=', 'u.id')->leftJoin('prepaid_vouchers as v', 'v.id', '=', 'r.voucher_id')->leftJoin('voucher_limits as l', 'l.id', '=', 'v.limit_id')->where('u.uname', $this->uname);
if ($acctsessionid == NULL && $acctuniqueid == NULL) {
$settings = Capsule::table('general_settings as s')->select('s.idle_timeout')->first();
if ($settings->idle_timeout != 0) {
$this->user->idleTimeout = $settings->idle_timeout;
}
}
if ($acctsessionid != NULL and $acctuniqueid != NULL) {
$q->join('radacct as a', 'u.uname', '=', 'a.username')->where('a.')->addSelect('a.acctinputoctets', 'a.acctoutputoctets', 'a.acctsessiontime', 'r.active_tpl');
}
$this->user = $q->first();
if ($this->user == NULL) {
reject("No such user: {$this->uname}");
}
$this->status['isActive'] = $this->user->status;
$this->status['isLimited'] = $this->user->plan_type;
$this->status['isUnlimited'] = !$this->user->plan_type;
$this->status['haveAQAccess'] = $this->user->aq_access ? TRUE : FALSE;
return $this;
}
示例7: shouldRejectIfAnyInputPromiseRejectsBeforeDesiredNumberOfInputsAreResolved
/** @test */
public function shouldRejectIfAnyInputPromiseRejectsBeforeDesiredNumberOfInputsAreResolved()
{
$mock = $this->createCallableMock();
$mock->expects($this->once())->method('__invoke')->with($this->identicalTo([1 => 2, 2 => 3]));
some([resolve(1), reject(2), reject(3)], 2)->then($this->expectCallableNever(), $mock);
}
示例8: contentStream
/**
* Get the message content as a stream.
*
* @see IncomingMessage::content() to get the content as a string.
*
* @see IncomingMessage::contentUnbuffered() to get the message content as
* it becomes available.
*
* Closing the stream discards any remaining content.
*
* If the message does not contain any content, the stream will be closed
* before it is returned, and no stream events will be emitted.
*
* @see ReadableStreamInterface::isReadable() to check if a stream can be read from.
*
* @return ReadableStreamInterface A stream containing the message content.
* @throws LogicException The message content has already been consumed or discarded.
*/
public function contentStream()
{
if ($this->contentHandled) {
return reject(new LogicException('The message content has already been consumed or discarded.'));
}
$this->contentHandled = true;
$stream = new MemoryStream();
$stream->on('close', $this->cancelContentListener);
if (0 === $this->headerFrame->contentLength) {
$stream->close();
} else {
$this->onBodyFrame = function ($exception, $frame, $final) use($stream) {
if ($exception) {
$stream->close($exception);
} elseif ($final) {
$stream->end($frame->content);
} else {
$stream->write($frame->content);
}
};
}
return $stream;
}
示例9: reject
reject('ltrim', TRUE)->equals('');
reject('Dotink\\Lab\\Calculator::$seed', TRUE)->measures(23);
}, 'Contains Rejections' => function ($data) {
reject('This is a test string')->contains('foo');
reject('This is a test string')->contains('FOO', FALSE);
assert(function () {
reject('This is a test string')->contains('test');
})->throws('Dotink\\Lab\\FailedTestException');
assert(function () {
reject('This is a test string')->contains('TEST', FALSE);
})->throws('Dotink\\Lab\\FailedTestException');
assert(function () {
reject('This is a test string')->contains('test', TRUE);
})->throws('Dotink\\Lab\\FailedTestException');
reject(['a' => 'foo', 'b' => 'bar'])->contains('hello');
reject(function () {
reject(['a' => 'foo', 'b' => 'bar'])->contains('foobar');
})->throws('Dotink\\Lab\\FailedTestException');
reject(['a' => 'foo', 'b' => 'bar'])->has('b', 'c');
assert(function () {
reject(['a' => 'foo', 'b' => 'bar'])->has('b');
})->throws('Dotink\\Lab\\FailedTestException');
}, 'Ends and Begins Rejections' => function ($data) {
reject('I have a merry band of brothers')->begins('I have the')->ends('group of brothers');
assert(function () {
reject('I have a merry band of brothers')->begins('I have');
})->throws('Dotink\\Lab\\FailedTestException');
assert(function () {
reject('I have a merry band of brothers')->ends('band of brothers');
})->throws('Dotink\\Lab\\FailedTestException');
}]];
示例10: shouldRejectIfAnyInputPromiseRejects
/** @test */
public function shouldRejectIfAnyInputPromiseRejects()
{
$mock = $this->createCallableMock();
$mock->expects($this->once())->method('__invoke')->with($this->identicalTo(2));
all([resolve(1), reject(2), resolve(3)])->then($this->expectCallableNever(), $mock);
}
示例11: shouldResolveWhenFirstInputPromiseResolves
/** @test */
public function shouldResolveWhenFirstInputPromiseResolves()
{
$mock = $this->createCallableMock();
$mock->expects($this->once())->method('__invoke')->with($this->identicalTo(1));
any([resolve(1), reject(2), reject(3)])->then($mock);
}
示例12: test_reject
public function test_reject()
{
assert_equal(array(1, 3), reject(array(1, 2, 3, 4), function ($v) {
return $v % 2 == 0;
}));
}
示例13: array
// array('confirm' => 'Are you sure you want to delete this conference?', "visible" => $ismoderator, 'role' => "button", "class" => "btn btn-danger")
// );
if ($model->status != "cancelled") {
$html .= CHtml::ajaxLink('Cancel', Yii::app()->createAbsoluteUrl('videoConference/cancel/' . $model->id), array('type' => 'post', 'data' => array('id' => $model->id, 'type' => 'post'), 'update' => 'message', 'success' => 'function(response) {
$(".message").html(response);
location.reload();
}'), array('confirm' => 'Are you sure you want to cancel this conference?', "visible" => $ismoderator, 'role' => "button", "class" => "btn btn-warning"));
}
} else {
$invitation = VCInvitation::model()->findByAttributes(array('videoconference_id' => $model->id, 'invitee_id' => $user->id));
if ($invitation->status == "Unknown") {
$html .= accept($model->id);
$html .= reject($model->id);
} else {
if ($invitation->status == "Accepted") {
$html .= reject($model->id);
} else {
$html .= accept($model->id);
}
}
}
$html .= "</div>";
$html = str_replace("%SUBJECT%", $model->subject, $html);
$html = str_replace("%MSTATUS%", $model->status, $html);
if ($model->status == "cancelled") {
$html = str_replace("%STATUS%", "<p style='font-weight: bold'>Status: Cancelled</p>", $html);
} else {
$html = str_replace("%STATUS%", "", $html);
}
$html = str_replace("%SUBJECT%", $model->subject, $html);
$html = str_replace("%DATE%", $user_friendly_date, $html);
示例14: last
/**
* Perform a GET request against the link's "last" relation
*
* @return ExtendedPromiseInterface
*/
function last() : ExtendedPromiseInterface
{
if ($this->links() && ($last = $this->links()->getLast())) {
return $this->withUrl($last)->get();
}
return reject($this->links());
}
示例15: shouldRejectWhenInputPromiseRejects
/** @test */
public function shouldRejectWhenInputPromiseRejects()
{
$mock = $this->createCallableMock();
$mock->expects($this->once())->method('__invoke')->with($this->identicalTo(null));
reduce(reject(), $this->plus(), 1)->then($this->expectCallableNever(), $mock);
}