last() public method

{@inheritDoc}
public last ( )
 public function last()
 {
     if (null === $this->entries) {
         $this->__load___();
     }
     return $this->entries->last();
 }
 /**
  *
  * @return ServiceEvent
  */
 public function getServiceEvent()
 {
     if (!$this->serviceEvents) {
         $serviceEvent = new ServiceEvent();
         $this->setServiceEvent($serviceEvent);
     }
     return $this->serviceEvents->last();
 }
示例#3
0
 public function append($output, $error)
 {
     $processOutput = new ProcessOutput();
     $last = $this->outputs->last();
     $processOutput->setNumber($last ? ++$last->number : 1);
     $processOutput->setCreated(new \DateTime());
     $processOutput->setValue($output);
     $processOutput->setError($error);
     $processOutput->setProcess($this);
     $this->outputs[] = $processOutput;
 }
示例#4
0
文件: Trip.php 项目: jff15/travelbot
 /**
  * @param string
  * @param string
  * @param array	 	 
  */
 public function __construct($departure, $arrival, array $steps = array())
 {
     $this->departure = (string) $departure;
     $this->arrival = (string) $arrival;
     $this->steps = new ArrayCollection();
     foreach ($steps as $step) {
         $this->addStep($step);
     }
     if ($this->steps->last() != NULL) {
         $this->lastSequenceOrder = $this->steps->last()->sequenceOrder;
     }
 }
示例#5
0
 public function getSessions(Event $event)
 {
     $sessions = new ArrayCollection();
     $this->crawler->filter('#snippet--program dt')->each(function (Crawler $dt) use($sessions, $event) {
         $session = new Session();
         $session->setEvent($event);
         $time = new \DateTime($dt->text(), new \DateTimeZone('Europe/Prague'));
         $date = clone $event->getStart();
         $date->setTime($time->format('H'), $time->format('i'), $time->format('s'));
         $session->setStart($date);
         if ($previousSession = $sessions->last()) {
             $previousSession->setStop($date);
         }
         $sessions->add($session);
     });
     $this->crawler->filter('#snippet--program dd')->each(function (Crawler $dd, $i) use($sessions) {
         $session = $sessions[$i];
         if (preg_match('/program-type-([^ ]+)/', $dd->attr('class'), $matches)) {
             $session->setType($matches[1]);
         }
         $title = $dd->filter('.program-title');
         $speaker = $dd->filter('.program-speaker');
         $description = $dd->filter('.program-desc');
         if (count($title)) {
             $session->setTitle(trim($title->text()));
         }
         if (count($speaker)) {
             $session->setSpeaker(trim($speaker->text()));
         }
         if (count($description)) {
             $session->setDescription(trim($description->text()));
         }
     });
     return $sessions;
 }
示例#6
0
 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;
 }
 /**
  * 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);
 }
示例#8
0
 public function indexAction(Application $app, Request $request, $url)
 {
     if ($url) {
         $urlParts = new ArrayCollection(explode('/', $url));
         $last = $urlParts->last();
         $page = $app['em']->getRepository('CMSilex\\Entities\\Page')->findOneBy(['slug' => $last]);
         if ($page) {
             $template = $page->getTemplate();
             return $app->render('@theme/' . $template . '.html.twig', ['page' => $page]);
         } else {
             throw new NotFoundHttpException();
         }
     }
     throw new NotFoundHttpException();
 }
示例#9
0
 /**
  * @return StationState
  */
 public function getCurrentStationState()
 {
     return $this->stationStates->last();
 }
示例#10
0
 /**
  * {@inheritdoc}
  */
 public function getLastState()
 {
     return $this->states->last() ?: null;
 }
示例#11
0
 /**
  * Sets the internal iterator to the last element in the collection and returns this element.
  *
  * @return mixed
  */
 public function last()
 {
     return $this->collection->last();
 }
示例#12
0
 /** {@inheritDoc} */
 public function last()
 {
     $this->initialize();
     return $this->collection->last();
 }
示例#13
0
 /**
  * @dataProvider getNodes
  *
  * @param int $total_pages
  * @param string|\Closure $page_link
  * @param string $first_page_link
  * @param ArrayCollection $list
  */
 public function testGetIterator($total_pages, $page_link, $first_page_link, $list)
 {
     $current_page = 1;
     foreach ($list as $node) {
         /** @var $node Node */
         if ($node->isCurrent()) {
             $current_page = $node->getPage();
         }
     }
     $left_offset = $current_page - $list->first()->getPage();
     $right_offset = $list->last()->getPage() - $current_page;
     if ($list->first()->getPage() == 1) {
         $this->config->expects($this->once())->method('getFirstPageLink')->will($this->returnValue($first_page_link));
     } else {
         $this->config->expects($this->never())->method('getFirstPageLink');
     }
     $this->config->expects($this->once())->method('getTotalPages')->will($this->returnValue($total_pages));
     $this->config->expects($this->atLeastOnce())->method('getCurrentPage')->will($this->returnValue($current_page));
     $this->config->expects($this->atLeastOnce())->method('getPageLink')->will($this->returnValue($page_link));
     $this->range->expects($this->once())->method('getLeftOffset')->will($this->returnValue($left_offset));
     $this->range->expects($this->once())->method('getRightOffset')->will($this->returnValue($right_offset));
     $this->assertEquals($list, $this->view->getIterator());
 }
 /**
  * Tests IdentityWrapper->last()
  */
 public function testLast()
 {
     $expected = end($this->entries);
     $this->assertSame($expected, $this->identityWrapper->last());
     $this->assertSame($expected, $this->wrappedCollection->last());
 }
示例#15
0
文件: AbstractElo.php 项目: avoo/elo
 /**
  * Get estimate points
  *
  * @param EloPlayerInterface $player
  *
  * @return integer
  */
 private function estimateRange(EloPlayerInterface $player)
 {
     $baseRange = new ArrayCollection($this->configuration->getBaseRange());
     $keys = array_keys($this->configuration->getBaseRange());
     $estimatedRange = $baseRange->first();
     $i = 0;
     foreach ($baseRange as $eloMin => $range) {
         if (!isset($keys[$i + 1]) && $player->getElo() > $baseRange->last()) {
             $estimatedRange = $baseRange->last();
             break;
         }
         if ($player->getElo() >= $eloMin && isset($keys[$i + 1]) && $player->getElo() <= $keys[$i + 1]) {
             $estimatedRange = $range;
             break;
         }
         $i++;
     }
     return $estimatedRange;
 }
 function last()
 {
     return $this->fields->last();
 }
示例#17
0
 /**
  * @inheritdoc
  * @todo change since and flags to array of options after implementing another VCS type.
  */
 public function commits($since = '', $flags = 0)
 {
     // if (!$this->isDeployed()) {
     //    // @todo throw exception or clone
     // }
     $commandParts = [];
     $commandParts['executable'] = (string) $this->gitExecutablePath;
     $commandParts['remotePath'] = '-C "' . $this->repoPath . '"';
     $commandParts['action'] = 'log --date=iso --numstat';
     $commandParts['option-no-merges'] = $this->hasFlag(VCS_FLAG_NO_MERGES, $flags) ? '--no-merges' : '';
     $commandParts['option-no-walk'] = $this->hasFlag(VCS_FLAG_NO_WALK, $flags) ? '--no-walk' : '';
     $commandParts['option-tags'] = $this->hasFlag(VCS_FLAG_TAGS, $flags) ? '--tags' : '';
     $commandParts['format'] = '--pretty=format:"{\\"commit\\":\\"%H\\",\\"committer_name\\":\\"%cN\\",\\"committer_email\\":\\"%cE\\",\\"committer_date\\":\\"%ci\\",\\"subject\\":\\"%f\\"}"';
     $commandParts['since'] = strlen($since) > 0 ? '--since="' . $since . '"' : '';
     $commandString = implode(' ', array_filter($commandParts));
     $extractListing = new ArrayCollection($this->launcher->run($commandString));
     $responseListing = new ArrayCollection();
     $state = [];
     $extractListing->forAll(function ($index, $item) use($responseListing, &$state) {
         switch (true) {
             case trim($item) === '':
                 break;
             case substr($item, 0, 1) === '{':
                 // adding an item that didn't have changed files (successive log entries)
                 if (count($state) > 0) {
                     $commit = Commit::build($state);
                     $responseListing->set($commit->sha, $commit);
                 }
                 $state = json_decode($item, true);
                 $state['changes'] = [];
                 break;
             default:
                 $parts = explode("\t", $item);
                 if (count($parts) === 3 && $responseListing->count() > 0) {
                     $responseListing->last()->putChangedFile($parts[2], $parts[0], $parts[1]);
                 }
                 break;
         }
         return true;
     });
     return $responseListing;
 }
示例#18
0
 /**
  * @return Comment
  */
 public function getLastComment()
 {
     return $this->comments->last();
 }
示例#19
0
 /**
  * Get last version
  *
  * @return Version
  */
 public function getLastVersioin()
 {
     return $this->versions->last();
 }
示例#20
0
 /**
  * @dataProvider provideDifferentElements
  */
 public function testLast($elements)
 {
     $collection = new ArrayCollection($elements);
     $this->assertSame(end($elements), $collection->last());
 }
示例#21
0
 /**
  * {@inheritdoc}
  */
 public function getLastCallee()
 {
     return $this->calledUsers->last();
 }