public function visitValues(Requests\Values $request) { switch ($request->getValuesType()) { case Requests\Values::AS_SELF: return $this->traversable; case Requests\Values::AS_ARRAY: return $this->traversable->asArray(); case Requests\Values::AS_ARRAY_COMPATIBLE_ITERATOR: return $this->traversable->getIterator(); case Requests\Values::AS_TRUE_ITERATOR: return $this->traversable->getTrueIterator(); case Requests\Values::AS_TRAVERSABLE: return $this->traversable->asTraversable(); case Requests\Values::AS_COLLECTION: return $this->traversable->asCollection(); } }
protected final function assertMatchesValues(\Pinq\ITraversable $traversable, array $array, $message = '') { $firstIterationArray = []; foreach ($traversable as $key => $value) { $firstIterationArray[] = $value; } $secondIterationArray = []; foreach ($traversable as $key => $value) { $secondIterationArray[] = $value; } $explicitArray = array_values($traversable->asArray()); $array = array_values($array); $this->assertSame($array, $firstIterationArray, $message); $this->assertSame($array, $secondIterationArray, $message); $this->assertSame($array, $explicitArray, $message); }