/** * @param string $code * @return string */ private function applyFilters(string $code) : string { $this->filters->apply(function ($filter) use(&$code) { $code = $filter($code); }); return $code; }
/** * @expectedException \Exception * @expectedExceptionMessage Serialization of 'Closure' is not allowed */ public function testThatCollectionIsNotSerializableAfterQueriesWithClosures() { $collection = Collection::from(range(1, 10)); $collection = $collection->where(function ($i) { return $i !== false; }); serialize($collection); }
/** * @param string $basePath * @return Collection */ public function extractPaths(string $basePath) : Collection { if (is_dir($basePath)) { return Collection::from(glob($basePath . '/*.md')); } else { return Collection::from([$basePath]); } }
public function offsetUnset($index) { if ($this->source !== null) { $this->source->offsetUnset($index); } else { $this->toOrderedMap()->offsetUnset($index); } }
protected function retrieveValues(\PDOStatement $statement) { $statement->setFetchMode(\PDO::FETCH_ASSOC); switch ($this->retrievalMode) { case Values::AS_ARRAY: return $statement->fetchAll(); case Values::AS_ARRAY_COMPATIBLE_ITERATOR: return new \IteratorIterator($statement); case Values::AS_TRUE_ITERATOR: return new \IteratorIterator($statement); case Values::AS_TRAVERSABLE: return Traversable::from($statement); case Values::AS_COLLECTION: return Collection::from($statement); default: throw new PinqDemoSqlException('Unsupported value retrieval mode'); } }