Example #1
0
 /**
  * Finish join
  * @param \qinq\Object\Query\callable $callable
  * @return \qinq\Collection
  */
 public function to(callable $callable)
 {
     $result = $this->computeGroupResult($callable);
     $query = $this->getQuery();
     $collection = $this->getCollection();
     if ($query instanceof qinq\Query\Immutable) {
         $collection = new qinq\Collection($result);
     } elseif ($query instanceof qinq\Query\Mutable) {
         $collection->from($result);
     }
     return $collection;
 }
Example #2
0
 function testIntegratedFrom()
 {
     $numbers = new qinq\Collection();
     $matches = [10, 20, 30];
     foreach ($numbers->from(range(1, 3))->select(function ($n) {
         return $n * 10;
     }) as $number) {
         $match = array_shift($matches);
         $this->assertEquals($match, $number);
     }
 }