当前位置: 首页>>代码示例>>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;未经允许,请勿转载。