@@ -94,7 +94,7 @@ public function process(CodeCoverage $coverage, string $target): void
9494 $ id = $ node ->getId ();
9595
9696 if ($ node instanceof DirectoryNode) {
97- if (!@ \mkdir ( $ target . $ id , 0777 , true ) && ! \is_dir ($ target . $ id )) {
97+ if (!$ this -> createDirectory ($ target . $ id )) {
9898 throw new \RuntimeException (\sprintf ('Directory "%s" was not created ' , $ target . $ id ));
9999 }
100100
@@ -103,7 +103,7 @@ public function process(CodeCoverage $coverage, string $target): void
103103 } else {
104104 $ dir = \dirname ($ target . $ id );
105105
106- if (!@ \mkdir ( $ dir , 0777 , true ) && ! \is_dir ($ dir )) {
106+ if (!$ this -> createDirectory ($ dir )) {
107107 throw new \RuntimeException (\sprintf ('Directory "%s" was not created ' , $ dir ));
108108 }
109109
@@ -161,7 +161,7 @@ private function getDirectory(string $directory): string
161161 $ directory .= DIRECTORY_SEPARATOR ;
162162 }
163163
164- if (!@ \mkdir ( $ directory , 0777 , true ) && ! \is_dir ($ directory )) {
164+ if (!$ this -> createDirectory ($ directory )) {
165165 throw new RuntimeException (
166166 \sprintf (
167167 'Directory "%s" does not exist. ' ,
@@ -172,4 +172,9 @@ private function getDirectory(string $directory): string
172172
173173 return $ directory ;
174174 }
175+
176+ private function createDirectory (string $ directory ): bool
177+ {
178+ return !(!\is_dir ($ directory ) && !@\mkdir ($ directory , 0777 , true ) && !\is_dir ($ directory ));
179+ }
175180}
0 commit comments