Skip to content

Commit

Permalink
adds file close
Browse files Browse the repository at this point in the history
stick it to stickler
  • Loading branch information
thinkingmedia committed Jun 28, 2016
1 parent 738726a commit bb79e5a
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/Console/Shell.php
Expand Up @@ -806,14 +806,19 @@ public function createFile($path, $contents)
}

$File = new File($path, true);
if ($File->exists() && $File->writable()) {
$File->write($contents);
$this->_io->out(sprintf('<success>Wrote</success> `%s`', $path));
return true;
}

$this->_io->err(sprintf('<error>Could not write to `%s`</error>.', $path), 2);
return false;
try {
if ($File->exists() && $File->writable()) {
$File->write($contents);
$this->_io->out(sprintf('<success>Wrote</success> `%s`', $path));
return true;
}

$this->_io->err(sprintf('<error>Could not write to `%s`</error>.', $path), 2);
return false;
} finally {
$File->close();
}
}

/**
Expand Down

0 comments on commit bb79e5a

Please sign in to comment.