本文整理汇总了PHP中Illuminate\Support\Collection::reject方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::reject方法的具体用法?PHP Collection::reject怎么用?PHP Collection::reject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Collection
的用法示例。
在下文中一共展示了Collection::reject方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateForm
/**
* Compile the final form
*
* @return string
*/
protected function generateForm()
{
$form = $this->generateTag($this->form->pull(0));
/**
* Remove Empty Items
*/
$this->form = $this->form->reject(function ($obj) {
return $obj instanceof Collection ? $obj->isEmpty() : false;
});
return $this->form->map(function ($item) {
/**
* Remove ErrorBox if there is no error
*/
if ($item instanceof Collection && $item->get('element') == 'errorMessage' && $item->get('errors') === null) {
return false;
}
/**
* Generate tag if $item is not empty
*/
if ($item instanceof Collection) {
/**
* Detect Errors
*/
$error = $this->appendErrors($item);
return $this->wrap($item, $error);
}
/**
* Return item if it`s just an string
*/
return $item;
})->prepend($form)->implode('');
}
示例2: removeItems
/**
* @param array $query
* @return array
*/
public function removeItems(array $query)
{
$result = [];
$items = $this->_items->reject(function ($value) use($query, $result) {
foreach ($query as $k => $v) {
if (isset($value['buyable'][$k]) and $value['buyable'][$k] != $v) {
return false;
}
}
$this->_totalPrice -= $value['buyable']['price'] * $value['amount'];
$result[] = $value;
return true;
});
$this->_items = $items;
return $result;
}
示例3: popCriteria
/**
* Pop Criteria
*
* @param $criteria
*
* @return $this
*/
public function popCriteria($criteria)
{
$this->criteria = $this->criteria->reject(function ($item) use($criteria) {
if (is_object($item) && is_string($criteria)) {
return get_class($item) === $criteria;
}
if (is_string($item) && is_object($criteria)) {
return $item === get_class($criteria);
}
return get_class($item) === get_class($criteria);
});
return $this;
}
示例4: displayConnectionErrors
protected function displayConnectionErrors(Collection $backupDestinationStatuses)
{
$unreachableBackupDestinationStatuses = $backupDestinationStatuses->reject(function (BackupDestinationStatus $backupDestinationStatus) {
return $backupDestinationStatus->isReachable();
});
if ($unreachableBackupDestinationStatuses->isEmpty()) {
return;
}
$this->warn('');
$this->warn('Unreachable backup destinations');
$this->warn('-------------------------------');
$unreachableBackupDestinationStatuses->each(function (BackupDestinationStatus $backupStatus) {
$this->warn("Could not reach backups for {$backupStatus->backupName()} on disk {$backupStatus->getFilesystemName()} because:");
$this->warn($backupStatus->connectionError()->getMessage());
$this->warn('');
});
}
示例5: filterNotifications
/**
* @param $level
*
* @return \Illuminate\Support\Collection|static
*/
protected function filterNotifications($level)
{
if (is_string($level)) {
$level = explode('|', $level);
}
if (is_array($level)) {
$levels = [0 => 0];
foreach ($level as $l) {
$l = array_get($this->levels, $l, 0);
$levels[$l] = $l;
}
$notifications = $this->messages->reject(function ($notification) use($levels) {
return !array_key_exists($notification['sort'], $levels);
});
return $notifications;
}
return new Collection();
}
示例6: compile
/**
* @param CommandContextInterface $commandContext
* @return Collection
*/
protected function compile(CommandContextInterface $commandContext)
{
$this->logFile = storage_path('logs/async/' . (string) round(microtime(true) * 1000) . mt_rand(1, 10000) . '.log');
$memoryLimit = config('satis.memory_limit');
$buildVerbosity = config('satis.build_verbosity');
$chunks = new Collection(['php' . ($memoryLimit !== null ? ' -dmemory_limit=' . $memoryLimit : ''), sprintf($this->executable, DIRECTORY_SEPARATOR), $this->command . ($buildVerbosity !== null ? ' -' . $buildVerbosity : ''), $this->configPath, $this->buildDirectory]);
if ($this->item !== null) {
$chunks->push($this->item);
}
$chunks->push($commandContext->getOutputRedirection($this->logFile));
$chunks->push($commandContext->getShouldUnlockOnCompletion());
foreach (['http', 'https'] as $protocol) {
$proxy = $this->proxySettings->get($protocol);
if ($proxy !== null) {
$chunks->prepend(strtoupper($protocol) . '_PROXY=' . $proxy);
}
}
$chunks->reject(function ($commandChunk) {
return trim($commandChunk) === '';
});
return $chunks;
}
示例7: remove
/**
* Remove permission by id
*
* @param mixed $id
* @return void
*/
public function remove($id)
{
$this->items->reject(function ($value, $key) use($id) {
return $value[$this->id] != $id;
});
}
示例8: testRejectRemovesElementsPassingTruthTest
public function testRejectRemovesElementsPassingTruthTest()
{
$c = new Collection(['foo', 'bar']);
$this->assertEquals(['foo'], $c->reject('bar')->values()->all());
$c = new Collection(['foo', 'bar']);
$this->assertEquals(['foo'], $c->reject(function ($v) {
return $v == 'bar';
})->values()->all());
$c = new Collection(['foo', null]);
$this->assertEquals(['foo'], $c->reject(null)->values()->all());
$c = new Collection(['foo', 'bar']);
$this->assertEquals(['foo', 'bar'], $c->reject('baz')->values()->all());
$c = new Collection(['foo', 'bar']);
$this->assertEquals(['foo', 'bar'], $c->reject(function ($v) {
return $v == 'baz';
})->values()->all());
$c = new Collection(['id' => 1, 'primary' => 'foo', 'secondary' => 'bar']);
$this->assertEquals(['primary' => 'foo', 'secondary' => 'bar'], $c->reject(function ($item, $key) {
return $key == 'id';
})->all());
}
示例9: removeProcessedUrlsFromPending
public function removeProcessedUrlsFromPending()
{
$this->pending = $this->pending->reject(function (CrawlUrl $crawlUrl) {
return $this->contains($this->processed, $crawlUrl);
})->values();
}
示例10: includedDirectories
protected function includedDirectories() : array
{
return $this->includeFilesAndDirectories->reject(function ($path) {
return is_file($path);
})->toArray();
}