Skip to content

Commit

Permalink
Add validation to create files on generator class (#252)
Browse files Browse the repository at this point in the history
* Add validation to create files on generator class

* Change parameters[path] to dirname on exception
  • Loading branch information
hjuarez20 authored and jmolivas committed Dec 5, 2017
1 parent e8939af commit 90bdec7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Generator/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,14 @@ protected function renderFile(
$flag = null
) {
if (!is_dir(dirname($target))) {
mkdir(dirname($target), 0777, true);
if(!mkdir(dirname($target), 0777, true)){
throw new \InvalidArgumentException(
sprintf(
'Path "%s" is invalid. You need to provide a valid path.',
dirname($target)
)
);
}
}

$currentLine = 0;
Expand Down

0 comments on commit 90bdec7

Please sign in to comment.