Code Duplication    Length = 4-4 lines in 3 locations

src/SilverStripe/BehatExtension/Context/BasicContext.php 3 locations

@@ 291-294 (lines=4) @@
288
        \Filesystem::makeFolder($path);
289
        $path = realpath($path);
290
291
        if (!file_exists($path)) {
292
            file_put_contents('php://stderr', sprintf('"%s" is not valid directory and failed to create it' . PHP_EOL, $path));
293
            return;
294
        }
295
296
        if (file_exists($path) && !is_dir($path)) {
297
            file_put_contents('php://stderr', sprintf('"%s" is not valid directory' . PHP_EOL, $path));
@@ 296-299 (lines=4) @@
293
            return;
294
        }
295
296
        if (file_exists($path) && !is_dir($path)) {
297
            file_put_contents('php://stderr', sprintf('"%s" is not valid directory' . PHP_EOL, $path));
298
            return;
299
        }
300
        if (file_exists($path) && !is_writable($path)) {
301
            file_put_contents('php://stderr', sprintf('"%s" directory is not writable' . PHP_EOL, $path));
302
            return;
@@ 300-303 (lines=4) @@
297
            file_put_contents('php://stderr', sprintf('"%s" is not valid directory' . PHP_EOL, $path));
298
            return;
299
        }
300
        if (file_exists($path) && !is_writable($path)) {
301
            file_put_contents('php://stderr', sprintf('"%s" directory is not writable' . PHP_EOL, $path));
302
            return;
303
        }
304
305
        $path = sprintf('%s/%s_%d.png', $path, basename($feature->getFile()), $step->getLine());
306
        $screenshot = $driver->getWebDriverSession()->screenshot();