last() публичный статический Метод

Example: $array = array('a', 'b', 'c'); $last = Arrays::last($array); Result: c
public static last ( array $elements ) : mixed
$elements array
Результат mixed
Пример #1
0
 /**
  * @return Event[]
  */
 public static function loadNew()
 {
     $lastEventId = Session::get('last_event_id');
     if (!$lastEventId) {
         //do not load events that we triggered before this session was started
         /** @var Event $lastEvent */
         $lastEvent = Event::queryBuilder()->limit(1)->order('id desc')->fetch();
         Session::set('last_event_id', $lastEvent ? $lastEvent->id : 0);
     }
     $events = Event::where(['id' => Restrictions::greaterThan($lastEventId)])->order('id asc')->fetchAll();
     if ($events) {
         Session::set('last_event_id', Arrays::last($events)->id);
     }
     return $events;
 }
Пример #2
0
 /**
  * @test
  * @expectedException \InvalidArgumentException
  */
 public function shouldThrowExceptionWhenElementsAreEmptyInLast()
 {
     //given
     $array = array();
     //when
     Arrays::last($array);
 }