Skip to content
Snippets Groups Projects
Commit a8a3985d authored by Stein Magne Bjorklund's avatar Stein Magne Bjorklund
Browse files

Cleanup Importer::createModels()

parent a79551ad
No related branches found
No related tags found
1 merge request!18Resolve "Remove all use of GLOBALS"
...@@ -208,7 +208,7 @@ final class Importer ...@@ -208,7 +208,7 @@ final class Importer
return $namespaces; return $namespaces;
} }
private function createModels($models) private function createModels($models): void
{ {
try { try {
foreach ($models as $k => $v) { foreach ($models as $k => $v) {
...@@ -217,17 +217,25 @@ final class Importer ...@@ -217,17 +217,25 @@ final class Importer
if (file_exists($path[$i])) { if (file_exists($path[$i])) {
if (!is_dir($path[$i])) { if (!is_dir($path[$i])) {
unlink($path[$i]); unlink($path[$i]);
mkdir($path[$i]); if (!mkdir($concurrentDirectory = $path[$i]) && !is_dir($concurrentDirectory)) {
throw new \RuntimeException(
sprintf('Directory "%s" was not created', $concurrentDirectory)
);
}
} }
} else { } elseif (!mkdir($concurrentDirectory = $path[$i]) && !is_dir($concurrentDirectory)) {
mkdir($path[$i]); throw new \RuntimeException(
sprintf('Directory "%s" was not created', $concurrentDirectory)
);
} }
chdir($path[$i]); chdir($path[$i]);
} }
$fh = fopen(end($path), 'w'); $fh = fopen(end($path), 'w');
fwrite($fh, $v); fwrite($fh, $v);
fclose($fh); fclose($fh);
for ($i = 0; $i < sizeof($path) - 1; $i++) { for ($i = 0; $i < sizeof($path) - 1; $i++) {
chdir('..'); chdir('..');
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment