public function testAccessors() { $dataset = uniqid(); $search = new Search($dataset); $search->setStart(10); $this->assertEquals(10, $search->getStart()); $search->setRows(5); $this->assertEquals(5, $search->getRows()); $search->setSort('test'); $this->assertEquals('test', $search->getSort()); $search->setLang('fr'); $this->assertEquals('fr', $search->getLang()); }
/** * @param array $parsed * @param Search $search * * @return array */ private function sortLocalData(array &$parsed, Search $search) { $sortKey = $search->getSort(); if (!empty($sortKey)) { $sorter = function ($key) { return function ($elt1, $elt2) use($key) { return strnatcmp($elt1[$key], $elt2[$key]); }; }; usort($parsed, $sorter($sortKey)); } return $parsed; }