本文整理汇总了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();
}
示例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]);
}
示例3: testCount
public function testCount()
{
$this->_coll[] = 'one';
$this->_coll[] = 'two';
$this->assertEquals($this->_coll->count(), 2);
$this->assertEquals(count($this->_coll), 2);
}
示例4: clearPreviousCollection
/**
* Resets previous photo collection
*
* @param Collection $collection
*/
protected function clearPreviousCollection(Collection $collection)
{
if ($collection->count()) {
foreach ($collection as $item) {
$collection->removeElement($item);
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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));
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例13: getShippingUnitCount
/**
* {@inheritdoc}
*/
public function getShippingUnitCount()
{
return $this->units->count();
}
示例14: getShippingItemCount
/**
* {@inheritdoc}
*/
public function getShippingItemCount()
{
return $this->items->count();
}
示例15: hasVariants
/**
* Tells if this product has variants.
*
* @return bool Product has variants
*/
public function hasVariants()
{
return $this->variants->count() > 0;
}