예제 #1
0
파일: Phinq.php 프로젝트: pablozabo/Diarco
 /**
  * @param array|Phinq|Iterator|IteratorAggregate $collection The initial collection to query on
  */
 protected function __construct($collection, array $queries = array())
 {
     $this->collection = Util::convertToNumericallyIndexedArray($collection);
     $this->evaluatedCollection = $this->collection;
     if (!empty($queries)) {
         foreach ($queries as $query) {
             $this->addToQueue($query);
         }
     }
 }
예제 #2
0
 /**
  * @link http://www.php.net/manual/en/function.array-multisort.php#90917
  * @return Closure
  */
 public function getSortingCallback()
 {
     //need to perform a multisort using callbacks... which PHP can't do natively
     $previousCallback = $this->previousQuery->getSortingCallback();
     $currentCallback = Util::getDefaultSortCallback($this->getLambdaExpression(), $this->isDescending());
     return function ($a, $b) use($previousCallback, $currentCallback) {
         $previousValue = $previousCallback($a, $b);
         if ($previousValue !== 0) {
             return $previousValue;
         }
         return $currentCallback($a, $b);
     };
 }
예제 #3
0
 public function getSortingCallback()
 {
     $lambda = $this->getLambdaExpression();
     return Util::getDefaultSortCallback($lambda, $this->isDescending());
 }