Skip to content

Commit

Permalink
Make cache file handling more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz committed Nov 28, 2023
1 parent eebe225 commit e252109
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/Supportive/DependencyInjection/ServiceContainerBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,21 @@ private static function loadServices(ContainerBuilder $container, ?SplFileInfo $
return;
}

$dirname = $cacheFile->getPath() ?: '.';

if ((
!is_dir($dirname)
&& mkdir($dirname.'/', 0777, true)
&& !is_dir($dirname)
) || (
!file_exists($cacheFile->getPathname())
&& !touch($cacheFile->getPathname())
&& !is_writable($cacheFile->getPathname())
)) {
throw CacheFileException::notWritable($cacheFile);
if (!file_exists($cacheFile->getPathname())) {
$dirname = $cacheFile->getPath() ?: '.';

if (!is_dir($dirname)
&& mkdir($dirname.'/', 0777, true)
&& !is_dir($dirname)
) {
throw CacheFileException::notWritable($cacheFile);
}

if (!touch($cacheFile->getPathname())
&& !is_writable($cacheFile->getPathname())
) {
throw CacheFileException::notWritable($cacheFile);
}
}

$container->setParameter('deptrac.cache_file', $cacheFile->getPathname());
Expand Down

0 comments on commit e252109

Please sign in to comment.