当前位置: 首页>>代码示例>>PHP>>正文


PHP Collection::reject方法代码示例

本文整理汇总了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('');
 }
开发者ID:SkysoulDesign,项目名称:TempArk,代码行数:37,代码来源:FormBuilder.php

示例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;
 }
开发者ID:whplay,项目名称:ohmate-shop,代码行数:20,代码来源:SessionDrivenCart.php

示例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;
 }
开发者ID:mammutgroup,项目名称:l5-repository,代码行数:20,代码来源:BaseRepository.php

示例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('');
     });
 }
开发者ID:spatie,项目名称:laravel-backup,代码行数:17,代码来源:ListCommand.php

示例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();
 }
开发者ID:znck,项目名称:flash,代码行数:23,代码来源:FlashNotifier.php

示例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;
 }
开发者ID:realshadow,项目名称:satis-control-panel,代码行数:26,代码来源:BuildCommand.php

示例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;
     });
 }
开发者ID:inoplate,项目名称:auth,代码行数:12,代码来源:Permission.php

示例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());
 }
开发者ID:sa7bi,项目名称:euro16,代码行数:21,代码来源:SupportCollectionTest.php

示例9: removeProcessedUrlsFromPending

 public function removeProcessedUrlsFromPending()
 {
     $this->pending = $this->pending->reject(function (CrawlUrl $crawlUrl) {
         return $this->contains($this->processed, $crawlUrl);
     })->values();
 }
开发者ID:spatie,项目名称:crawler,代码行数:6,代码来源:CrawlQueue.php

示例10: includedDirectories

 protected function includedDirectories() : array
 {
     return $this->includeFilesAndDirectories->reject(function ($path) {
         return is_file($path);
     })->toArray();
 }
开发者ID:spatie,项目名称:laravel-backup,代码行数:6,代码来源:FileSelection.php


注:本文中的Illuminate\Support\Collection::reject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。