Ejemplo n.º 1
0
 protected static function generateIfRequired()
 {
     $fs = new Filesystem();
     if (!isset(static::$values) || !isset(static::$records)) {
         static::$values = json_decode($fs->get(Path::join(__DIR__, 'data/values.json')), true)[0];
         static::$records = json_decode($fs->get(Path::join(__DIR__, 'data/records.json')), true);
     }
 }
 /**
  * render
  *
  * @param       $string
  * @param array $vars
  * @return string
  */
 public function render($string, array $vars = array())
 {
     $this->files->put($this->tmpFilePath, $this->compiler->compileString($string));
     if (is_array($vars) && !empty($vars)) {
         extract($vars);
     }
     ob_start();
     include $this->tmpFilePath;
     $var = ob_get_contents();
     ob_end_clean();
     $this->files->delete($this->tmpFilePath);
     return $var;
 }
Ejemplo n.º 3
0
 /**
  * generateDirectoryStructure
  *
  * @param       $destDir
  * @param array $dirs
  * @return $this
  */
 public function generateDirectoryStructure($destDir, array $dirs = [])
 {
     foreach ($dirs as $dirPath) {
         $dirPath = Path::join($destDir, $dirPath);
         if (!$this->files->exists($dirPath)) {
             $this->files->makeDirectory($dirPath, 0755, true);
         }
     }
     return $this;
 }
Ejemplo n.º 4
0
 public function testDumpFileOverwritesAnExistingFile()
 {
     $filename = $this->workspace . DIRECTORY_SEPARATOR . 'foo.txt';
     file_put_contents($filename, 'FOO BAR');
     $this->filesystem->dumpFile($filename, 'bar');
     $this->assertFileExists($filename);
     $this->assertSame('bar', file_get_contents($filename));
 }