當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Collection::count方法代碼示例

本文整理匯總了PHP中Doctrine\Common\Collections\Collection::count方法的典型用法代碼示例。如果您正苦於以下問題:PHP Collection::count方法的具體用法?PHP Collection::count怎麽用?PHP Collection::count使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\Common\Collections\Collection的用法示例。


在下文中一共展示了Collection::count方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: count

 /**
  * {@inheritdoc}
  */
 public function count()
 {
     if ($this->mapping['isInverseSide']) {
         $this->initialize();
     }
     return count($this->mongoData) + $this->coll->count();
 }
開發者ID:noc-med,項目名稱:mongodb-odm,代碼行數:10,代碼來源:PersistentCollection.php

示例2:

 function it_applies_choice_filter_on_datasource_for_collection_value(FilterDatasourceAdapterInterface $datasource, Collection $collection, $utility)
 {
     $collection->count()->willReturn(2);
     $collection->getValues()->willReturn(['foo', 'bar']);
     $utility->applyFilter($datasource, 'data_name_key', 'IN', ['foo', 'bar'])->shouldBeCalled();
     $this->apply($datasource, ['value' => $collection, 'type' => AjaxChoiceFilterType::TYPE_CONTAINS]);
 }
開發者ID:alexisfroger,項目名稱:pim-community-dev,代碼行數:7,代碼來源:ChoiceFilterSpec.php

示例3: testCount

 public function testCount()
 {
     $this->_coll[] = 'one';
     $this->_coll[] = 'two';
     $this->assertEquals($this->_coll->count(), 2);
     $this->assertEquals(count($this->_coll), 2);
 }
開發者ID:TuxCoffeeCorner,項目名稱:tcc,代碼行數:7,代碼來源:CollectionTest.php

示例4: clearPreviousCollection

 /**
  * Resets previous photo collection
  *
  * @param Collection $collection
  */
 protected function clearPreviousCollection(Collection $collection)
 {
     if ($collection->count()) {
         foreach ($collection as $item) {
             $collection->removeElement($item);
         }
     }
 }
開發者ID:pguso,項目名稱:WellCommerce,代碼行數:13,代碼來源:ProductPhotoCollectionToArrayTransformer.php

示例5: addUser

 /**
  * @param User $user
  *
  * @return Conversation
  */
 public function addUser($user)
 {
     if ($this->users->count() >= self::LIMIT_USERS) {
         throw new \BadMethodCallException('Conversations are only composed of ' . self::LIMIT_USERS . ' users');
     }
     $this->users->add($user);
     return $this;
 }
開發者ID:makanikki,項目名稱:messenger-api,代碼行數:13,代碼來源:Conversation.php

示例6: getProductReviewAverage

 /**
  * Returns product statuses
  *
  * @param int    $limit
  * @param string $orderBy
  * @param string $orderDir
  *
  * @return array
  */
 public function getProductReviewAverage(Collection $collection)
 {
     $totalRating = 0;
     $reviewsTotal = $collection->count();
     $collection->map(function (ProductReviewInterface $review) use(&$totalRating) {
         $totalRating += $review->getRating();
     });
     return $reviewsTotal > 0 ? round($totalRating / $reviewsTotal, 2) : 0;
 }
開發者ID:pguso,項目名稱:WellCommerce,代碼行數:18,代碼來源:ProductReviewExtension.php

示例7: count

 /**
  * {@inheritdoc}
  */
 public function count()
 {
     if ($this->mapping['isInverseSide'] && !$this->initialized) {
         $documentPersister = $this->uow->getDocumentPersister(get_class($this->owner));
         $count = empty($this->mapping['repositoryMethod']) ? $documentPersister->createReferenceManyInverseSideQuery($this)->count() : $documentPersister->createReferenceManyWithRepositoryMethodCursor($this)->count();
     } else {
         $count = $this->coll->count();
     }
     return count($this->mongoData) + $count;
 }
開發者ID:briareos,項目名稱:mongodb-odm,代碼行數:13,代碼來源:PersistentCollection.php

示例8: count

 /**
  * {@inheritdoc}
  */
 public function count()
 {
     $count = $this->coll->count();
     // If this collection is inversed and not initialized, add the count returned from the database
     if ($this->mapping['isInverseSide'] && !$this->initialized) {
         $documentPersister = $this->uow->getDocumentPersister(get_class($this->owner));
         $count += empty($this->mapping['repositoryMethod']) ? $documentPersister->createReferenceManyInverseSideQuery($this)->count() : $documentPersister->createReferenceManyWithRepositoryMethodCursor($this)->count();
     }
     return $count + ($this->initialized ? 0 : count($this->mongoData));
 }
開發者ID:dominium,項目名稱:mongodb-odm,代碼行數:13,代碼來源:PersistentCollectionTrait.php

示例9: transform

 /**
  * Transforms an ArrayCollection of Level entities to a
  * multi-line string showing the level names.
  *
  * @param Collection $levels
  *
  * @return string
  */
 public function transform($levels)
 {
     $serialized = '';
     if (!$levels instanceof Collection || $levels->count() === 0) {
         return $serialized;
     }
     foreach ($levels as $level) {
         $serialized .= $level->getName() . "\n";
     }
     return $serialized;
 }
開發者ID:claroline,項目名稱:distribution,代碼行數:19,代碼來源:LevelTransformer.php

示例10: transform

 /**
  * Transforms a collection of recipients into a string
  *
  * @param Collection $recipients
  *
  * @return string
  */
 public function transform($recipients)
 {
     if ($recipients->count() == 0) {
         return "";
     }
     $usernames = array();
     foreach ($recipients as $recipient) {
         $usernames[] = $this->userToUsernameTransformer->transform($recipient);
     }
     return implode(', ', $usernames);
 }
開發者ID:mattvaadi,項目名稱:hris,代碼行數:18,代碼來源:RecipientsDataTransformer.php

示例11: isDocumentSignaturesCompleted

 /**
  * Is all document signatures are completed
  *
  * @return bool
  */
 public function isDocumentSignaturesCompleted()
 {
     if (!$this->documentSignatures->count()) {
         return false;
     }
     foreach ($this->getDocumentSignatures() as $signature) {
         if (!$signature->isCompleted()) {
             return false;
         }
     }
     return true;
 }
開發者ID:junjinZ,項目名稱:wealthbot,代碼行數:17,代碼來源:Workflow.php

示例12: use

 function it_stores_only_unique_values(Collection $internal)
 {
     $container = [];
     $internal->add(Argument::type('string'))->will(function ($argument) use(&$container) {
         $container[] = $argument;
     });
     $internal->count()->will(function () use(&$container) {
         return count($container);
     });
     $internal->contains(Argument::type('string'))->will(function ($argument) use(&$container) {
         return in_array($argument, $container, true);
     });
     $this->add('t');
     $this->add('t');
     $this->add('d');
     $this->count()->shouldBe(2);
 }
開發者ID:Rybbow,項目名稱:x-blog,代碼行數:17,代碼來源:TypedCollectionSpec.php

示例13: getShippingUnitCount

 /**
  * {@inheritdoc}
  */
 public function getShippingUnitCount()
 {
     return $this->units->count();
 }
開發者ID:ahmadrabie,項目名稱:Sylius,代碼行數:7,代碼來源:Shipment.php

示例14: getShippingItemCount

 /**
  * {@inheritdoc}
  */
 public function getShippingItemCount()
 {
     return $this->items->count();
 }
開發者ID:sidibea,項目名稱:Sylius,代碼行數:7,代碼來源:Shipment.php

示例15: hasVariants

 /**
  * Tells if this product has variants.
  *
  * @return bool Product has variants
  */
 public function hasVariants()
 {
     return $this->variants->count() > 0;
 }
開發者ID:VictorMateo,項目名稱:elcodi,代碼行數:9,代碼來源:Product.php


注:本文中的Doctrine\Common\Collections\Collection::count方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。