Beispiel #1
0
 /**
  * @param $file_path
  *
  * @return bool
  *
  * @since 1.0.0
  */
 public function writeFile($format, $file_path)
 {
     switch ($format) {
         case 'php':
             if (!is_array($this->data)) {
                 throw new ConfigException('Config data must be an array to write php files');
             }
             $data = '<?php' . chr(13);
             $data .= 'return ' . var_export($this->data, true) . ';' . chr(13);
             break;
         case 'json':
             $data = json_encode($this->data);
             break;
     }
     FilesystemPath::create(dirname($file_path));
     return file_put_contents($file_path, $data);
 }