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


PHP ArrayCollection::count方法代码示例

本文整理汇总了PHP中Doctrine\Common\Collections\ArrayCollection::count方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayCollection::count方法的具体用法?PHP ArrayCollection::count怎么用?PHP ArrayCollection::count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\Common\Collections\ArrayCollection的用法示例。


在下文中一共展示了ArrayCollection::count方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: sameValueAs

 /**
  * @param Itinerary $other
  * @return bool
  */
 public function sameValueAs(Itinerary $other) : bool
 {
     //We use doctrine's ArrayCollection only to ease comparison
     //If Legs would be stored in an ArrayCollection hole the time
     //Itinerary itself would not be immutable,
     //cause a client could call $itinerary->legs()->add($anotherLeg);
     //Keeping ValueObjects immutable is a rule of thumb
     $myLegs = new ArrayCollection($this->legs());
     $otherLegs = new ArrayCollection($other->legs());
     if ($myLegs->count() !== $otherLegs->count()) {
         return false;
     }
     return $myLegs->forAll(function ($index, Leg $leg) use($otherLegs) {
         return $otherLegs->exists(function ($otherIndex, Leg $otherLeg) use($leg) {
             return $otherLeg->sameValueAs($leg);
         });
     });
 }
开发者ID:RossJHagan,项目名称:php-ddd-cargo-sample,代码行数:22,代码来源:Itinerary.php

示例2: testBind01

 public function testBind01()
 {
     $expectedJSON = file_get_contents(dirname(__DIR__) . '/../../Resources/json/client_aftership_couriers_response_handler_01.json');
     $this->response->expects($this->once())->method('getStatusCode')->will($this->returnValue(200));
     $this->response->expects($this->once())->method('getContent')->will($this->returnValue($expectedJSON));
     $this->responseHandler->bind($this->response, $this->collection);
     $this->assertEquals(26, $this->collection->count());
     $courier0 = $this->collection[0];
     $this->assertEquals('USPS', $courier0->getName());
     $this->assertEquals('United States Postal Service', $courier0->getOtherName());
     $this->assertEquals('+1 800-275-8777', $courier0->getPhone());
     $this->assertEquals(['USA'], $courier0->getServiceCountries());
     $this->assertEquals('usps', $courier0->getSlug());
     $this->assertEquals(['en'], $courier0->getSupportLanguages());
     $this->assertNotNull($courier0->getUpdatedAt());
     $this->assertEquals("https://www.usps.com", $courier0->getUrl());
     $courier13 = $this->collection[13];
     $this->assertEquals('Hong Kong Post', $courier13->getName());
     $this->assertEquals('香港郵政', $courier13->getOtherName());
     $this->assertEquals('+852 2921 2222', $courier13->getPhone());
     $this->assertEquals(['HKG'], $courier13->getServiceCountries());
     $this->assertEquals('hong-kong-post', $courier13->getSlug());
     $this->assertEquals(['en'], $courier13->getSupportLanguages());
     $this->assertNotNull($courier13->getUpdatedAt());
     $this->assertEquals("http://hongkongpost.com", $courier13->getUrl());
 }
开发者ID:antimattr,项目名称:shipment-tracking,代码行数:26,代码来源:CouriersAPIResponseHandlerTest.php

示例3: count

 public function count()
 {
     if (null === $this->entries) {
         return $this->repository->countByFeeds($this->feeds);
     }
     return $this->entries->count();
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:7,代码来源:AggregateEntryCollection.php

示例4: testOnSubmitDoNothing

 public function testOnSubmitDoNothing()
 {
     $submittedData = array('test');
     $event = new FormEvent($this->getForm(), $submittedData);
     $this->dispatcher->dispatch(FormEvents::SUBMIT, $event);
     $this->assertTrue($this->collection->contains('test'));
     $this->assertSame(1, $this->collection->count());
 }
开发者ID:symfony,项目名称:symfony,代码行数:8,代码来源:MergeDoctrineCollectionListenerTest.php

示例5: add

 public function add(IEntity $entity)
 {
     $this->errorOnInvalidEntityType($entity);
     if ($this->getIdentityValue($entity) < 1) {
         $this->setIdentityValue($entity, $this->collection->count() + 1);
     }
     $this->collection->set($entity->getId(), $entity);
 }
开发者ID:nebuchar,项目名称:ddd-blog,代码行数:8,代码来源:FakeRepository.php

示例6: isUnread

 /**
  * Gets whether the user has read this thread since the last post
  *
  * @param User $user
  *
  * @return boolean
  */
 public function isUnread(User $user)
 {
     if ($this->posts->count() === 0) {
         return false;
     }
     return $this->posts->last()->isUnread($user);
 }
开发者ID:madrakio,项目名称:streamperk-forum-bundle,代码行数:14,代码来源:ForumThread.php

示例7: getQBAliasReference

 public function getQBAliasReference($class, $attribute = NULL)
 {
     if (!is_object($class)) {
         throw new \Exception("object must be of type object, type %s given.", gettype($class));
     }
     $class_name = get_class($class);
     // get alias of class
     $alias = NULL;
     foreach ($this->qb_alias_reference->toArray() as $_class => $_alias) {
         if (isset($_alias[$class_name])) {
             $alias = $_alias[$class_name];
         }
     }
     // if not found
     if ($alias === NULL) {
         // if empty, set new
         if ($this->qb_alias_reference->count() == 0) {
             $alias = 'a';
             // get last and then count up
         } else {
             $lastAlias = $this->qb_alias_reference->last();
             $alias = ++$lastAlias[key($lastAlias)];
         }
         // add new
         $this->qb_alias_reference->add(array($class_name => $alias));
     }
     return $attribute === NULL ? $alias : $alias . '.' . $attribute;
 }
开发者ID:RSSfeed,项目名称:AdminBundle,代码行数:28,代码来源:AdminSearch.php

示例8: isAllDead

 /**
  * @param array $deadEntities
  * @return bool
  */
 protected function isAllDead(array $deadEntities)
 {
     if (count($deadEntities) == $this->existEntityCollection->count()) {
         return true;
     }
     return false;
 }
开发者ID:jarold87,项目名称:pingvin,代码行数:11,代码来源:ItemCollector.php

示例9: getMediaForThumbnail

 /**
  * @return AbstractMediaEntity|null
  */
 public function getMediaForThumbnail()
 {
     if ($this->media->count() > 0) {
         return $this->media->first();
     }
     return null;
 }
开发者ID:shefik,项目名称:MediaModule,代码行数:10,代码来源:CollectionEntity.php

示例10: removeChannel

 /**
  * {@inheritdoc}
  */
 public function removeChannel(ChannelInterface $channel)
 {
     $this->channels->removeElement($channel);
     if ($this->channels->count() === 0) {
         $this->activated = false;
     }
     return $this;
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:11,代码来源:Locale.php

示例11: setComments

 /**
  * Set Comments
  *
  * @param array $comments
  *
  * @return $this
  */
 public function setComments(array $comments)
 {
     foreach ($comments as $comment) {
         $this->addComments($comment);
     }
     $this->nbComments = $this->comments->count();
     return $this;
 }
开发者ID:Neirda24,项目名称:Aalto,代码行数:15,代码来源:Answer.php

示例12: getRoles

 public function getRoles()
 {
     if (!$this->roles->count()) {
         return array(parent::ROLE_DEFAULT);
     }
     $roles = $this->roles->toArray();
     foreach ($this->getGroups() as $group) {
         $roles = array_merge($roles, $group->getRoles());
     }
     foreach ($roles as $k => $role) {
         /* 
          * Ensure String[] to prevent bad unserialized UsernamePasswordToken with for instance 
          * UPT#roles:{Role('ROLE_USER'), 'ROLE_USER'} which ends in Error: Call to a member 
          * function getRole() on a non-object
          */
         $roles[$k] = $role instanceof RoleInterface ? $role->getRole() : (string) $role;
     }
     return array_flip(array_flip($roles));
 }
开发者ID:Varenthein,项目名称:find_bulb,代码行数:19,代码来源:User.php

示例13: testReverseTransform

 /**
  * @dataProvider transformDataProvider
  *
  * @param mixed $expected
  * @param mixed $value
  */
 public function testReverseTransform($expected, $value)
 {
     if (!$expected) {
         $expected = new ArrayCollection();
     }
     $this->doctrineHelper->expects($expected->isEmpty() ? $this->never() : $this->exactly($expected->count()))->method('getEntityReference')->will($this->returnCallback(function () {
         return $this->createDataObject(func_get_arg(1));
     }));
     $this->assertEquals($expected, $this->transformer->reverseTransform($value));
 }
开发者ID:Maksold,项目名称:platform,代码行数:16,代码来源:EntityChangesetTransformerTest.php

示例14: getCategory

 /**
  * @return Category
  */
 public function getCategory()
 {
     if ($this->enrollments->count() > 1) {
         throw new ValidationException("INVALIDENROLLMENT", "A team can not be enrolled for more than one category - team id=" . $this->id);
     }
     if ($this->enrollments->count() == 1) {
         return $this->enrollments->first()->getCategory();
     }
     return null;
 }
开发者ID:armandomeeuwenoord,项目名称:icup,代码行数:13,代码来源:Team.php

示例15: bulkInserts

 /**
  * @param  ArrayCollection $articles
  * @param  Integer         $batch_size
  */
 public function bulkInserts(ArrayCollection $articles, $batch_size = 20)
 {
     $length = $articles->count();
     for ($i = 1; $i < $length; ++$i) {
         $this->merge($articles->get($i));
         if (0 === $i % $batch_size) {
             $this->detaches();
         }
     }
     $this->detaches();
 }
开发者ID:ffff5912,项目名称:antena,代码行数:15,代码来源:ArticleRepository.php


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