for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Hyperized\Benchmark\Generic;
/**
* Class Directory
* @package Hyperized\Benchmark\Generic
*/
class Directory
{
* @var string
private static $rootPath = '.';
private static $parentPath = '..';
* @param $path
*
* http://php.net/manual/en/function.rmdir.php#119949
public static function removeRecursively($path): void
if (\file_exists($path)) {
$dir = \opendir($path);
if (\is_resource($dir)) {
while (false !== ($file = \readdir($dir))) {
if (($file !== self::$rootPath) && ($file !== self::$parentPath)) {
$full = $path . DIRECTORY_SEPARATOR . $file;
if (\is_dir($full)) {
self::removeRecursively($full);
} else {
\unlink($full);
}
\closedir($dir);
\rmdir($path);
* @param $permissions
* @return bool
* @throws \Exception
public static function create($path, $permissions = 0755): bool
if (!\file_exists($path) && !mkdir($path, $permissions) && !is_dir($path)) {
throw new \RuntimeException('Could not create directory: ' . $path);
return true;