Пример #1
0
 public function testClearCache()
 {
     $dir = Renderer::getCacheDir();
     Renderer::clearCache();
     $finder = new Finder();
     $finder->files()->name('*.php')->in($dir);
     $this->assertEquals(0, $finder->count());
 }
Пример #2
0
 /**
  * Randomly runs garbage collection on the image directory
  *
  * @return bool
  */
 public function collectGarbage()
 {
     if (!mt_rand(1, $this->gcFreq) == 1) {
         return false;
     }
     $this->createFolderIfMissing();
     $finder = new Finder();
     $criteria = sprintf('<= now - %s minutes', $this->expiration);
     $finder->in($this->webPath . '/' . $this->imageFolder)->date($criteria);
     foreach ($finder->files() as $file) {
         unlink($file->getPathname());
     }
     return true;
 }
Пример #3
0
 private function parseCSV()
 {
     $ignoreFirstLine = $this->csvParsingOptions['ignoreFirstLine'];
     $finder = new Finder();
     $finder->files()->in($this->csvParsingOptions['finder_in'])->name($this->csvParsingOptions['finder_name']);
     foreach ($finder as $file) {
         $csv = $file;
     }
     $rows = array();
     if (($handle = fopen($csv->getRealPath(), "r")) !== FALSE) {
         $i = 0;
         while (($data = fgetcsv($handle, null, ";")) !== FALSE) {
             $i++;
             if ($ignoreFirstLine && $i == 1) {
                 continue;
             }
             $rows[] = $data;
         }
         fclose($handle);
     }
     return $rows;
 }
 public function test_copy()
 {
     $finder = new Finder('tests/test-data/bigtree');
     $finder->files()->named('#\\.json#')->copyTo('tests/test-data-copy');
 }