當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。