/** * Class constructor. * * @param \Symfony\Component\HttpFoundation\File\File $info * @param string $mime_type * @param string $extension */ public function __construct(SymfonyFile $info, $mime_type = null, $extension = null) { // Symfony will help us guess things about this file $this->info = $info; // Sometimes we want to specify the MIME type ourselves $this->mime_type = $mime_type; // Sometimes we want to specify the extension ourselves $this->extension = $extension; // Get the SplFileObject from the SplFileInfo $this->object = $this->info->openFile(); // Kill any temporary files created in the lifetime of this object register_shutdown_function([$this, 'unlink']); }
/** * Constructor * * @param string $streetNames Path of the file containing the street names */ public function __construct($streetNames) { $file = new File($streetNames); $splFileObject = $file->openFile('r'); while (!$splFileObject->eof()) { $this->streetNames[] = trim($splFileObject->fgets()); } }
/** * Populate names from file to an array * * @param string $filename File name containing the names * * @return array * @author r1pp3rj4ck <*****@*****.**> */ private function populateNames($filename) { $names = array(); $file = new File($filename); $splFileObject = $file->openFile('r'); while (!$splFileObject->eof()) { $names[] = trim($splFileObject->fgets()); } return $names; }