コード例 #1
0
ファイル: Editor.php プロジェクト: lead-worker/redaktilo
 /**
  * By default opens existing files only, but can be forced to create new ones.
  *
  * @param string $filename
  * @param bool   $force
  *
  * @return File
  *
  * @throws \Symfony\Component\Filesystem\Exception\FileNotFoundException If the file hasn't be found.
  *
  * @api
  */
 public function open($filename, $force = false)
 {
     if (!$this->filesystem->exists($filename) && $force) {
         return $this->filesystem->create($filename);
     }
     return $this->filesystem->open($filename);
 }
コード例 #2
0
ファイル: EditorSpec.php プロジェクト: electrobits/redaktilo
 function it_cannot_open_new_files(Filesystem $filesystem, File $file)
 {
     $exception = new \Gnugat\Redaktilo\Exception\FileNotFoundException(self::FILENAME);
     $filesystem->exists(self::FILENAME)->willReturn(false);
     $filesystem->open(self::FILENAME)->willThrow($exception);
     $this->shouldThrow($exception)->duringOpen(self::FILENAME);
 }