Пример #1
0
 public function get_last($f3, $args)
 {
     $filter = json_decode(explode('=', $args[0])[1], true);
     // json -> array
     if ($filter['table']) {
         $table = new \DB\Jig\Mapper($this->db, $filter['table'] . '.json');
         echo json_encode(array(__::last(self::query_builder($filter, $table))));
     } else {
         Common::show_error('Table name required', 500);
     }
 }
function _last($array, $n = 1, $guard = false)
{
    return Underscore::last($array, $n, $guard);
}
Пример #3
0
 /**
  * @dataProvider peopleDataProvider
  * @tags arrays
  */
 public function testLast($people, $type, $meta)
 {
     // it should return the last list item
     $this->variable(_::last($people))->isEqualTo(_::get($people, 'rscott'));
     // it should return the last N list items
     $this->array(_::last($people, 3))->isEqualTo([_::get($people, 'ldicaprio'), _::get($people, 'nportman'), _::get($people, 'rscott')]);
     // it should always return an array when guard is true
     $this->array(_::last($people, 1, true))->isEqualTo([_::get($people, 'rscott')]);
     // it should return null if provided an empty list
     $this->variable(_::last([]))->isNull();
 }