Create a stamp form the modification time of the content of the given directory and all of its subdirectories

@param  string $directory ther directory name
@return string the stamp of this directory
14875
protected function getStamp($directory)
    {
        $stamp = '';

        $iterator = new \RecursiveIteratorIterator(
            new \RecursiveDirectoryIterator($directory, \RecursiveDirectoryIterator::SKIP_DOTS),
            \RecursiveIteratorIterator::LEAVES_ONLY
        );

        foreach ($iterator as $file) {
            $stamp .= $file->getMTime();
        }

        return md5($stamp);
    }
569022
public static function create($directory = '')
    {
        if (empty($directory) || !file_exists($directory)) {
            $directory = sys_get_temp_dir();
        }

        return new Wrapper($directory);
    }
42658
public function getPermittedFileName($directory, $filename) {

        /**
         * Get $pathInfo from $filename
         */
        $pathInfo = pathinfo($filename);

        /**
         * Max limit permitted $filename
         */
        $pathInfo['filename'] = substr(Inflector::slug($pathInfo['filename']), 0, 100);

        /**
         * Min limit permitted $filename
         */
        if (strlen($pathInfo['filename']) < 3)
            $pathInfo['filename'] = $this->_randomString();

        /**
         * 
         */
        $dir = new Folder($directory);
        $iter = 0;
        do {
            if ($iter == 0)
                $slugFileName = $pathInfo['filename'] . '.' . $pathInfo['extension'];
            else
                $slugFileName = $pathInfo['filename'] . '-' . $iter . '.' . $pathInfo['extension'];
            $data = $dir->find($slugFileName, true);
            $iter++;
        } while (count($data) > 0);

        return $slugFileName;
    }
652485
private function checkDirectoryExists(string $directory) : string
    {
        $realDirectory = realpath($directory);

        if (false === $realDirectory) {
            throw new DirectoryMissingException('The directory "' . $directory . '" does not exist, or we cannot access it');
        }

        if (!is_dir($realDirectory)) {
            throw new NotADirectoryException('The path "' . $realDirectory . '" did not resolve to a directory');
        }

        return $realDirectory;
    }
419081
public function mkdir($directory = null)
    {
        if (\ftp_mkdir($this->_stream, $directory)) {
            return true;
        }

        $this->error = 'Failed to create directory "'.$directory.'"';

        return false;
    }
1343481
public static function removeStartSlash($directory) : string
    {
        if (self::startsWithSlash($directory)) {
            $directory = substr($directory, 1);
        }
        return $directory;
    }
113585
public function files($directory)
    {
        return collect([])
            ->merge($this->filesystem->files($directory))
            ->map(function ($file) {
                return new File($file, $this);
            });
    }
435689
protected function _get_mod_time($dir)
	{
		// filemtime() may return false, but raises an error for non-existing files
		$date = file_exists($dir) ? getdate(filemtime($dir)) : getdate($this->now);

		return array(
			'file_mtime' => ($date['hours'] << 11) + ($date['minutes'] << 5) + $date['seconds'] / 2,
			'file_mdate' => (($date['year'] - 1980) << 9) + ($date['mon'] << 5) + $date['mday']
		);
	}
854839
public static function delTree($directory)
    {

        $files = array_diff(scandir($directory), array('.','..'));
		foreach ($files as $file) {
			$abspath = $directory.DIRECTORY_SEPARATOR.$file;
			if (is_dir($abspath)) {
				self::delTree($abspath);
			} else {
				unlink($abspath);
			}
		}
		return rmdir($directory);

    }
95825
public function save($directory)
    {
        $parts = explode('_', $this->getClass());
        array_unshift($parts, $directory);
        $path = join(DIRECTORY_SEPARATOR, $parts) . '.php';
        self::saveToFile($path, $this->getSrc());
    }
395922
protected function runDir($directory)
    {
        if (is_array($directory)) {
            return $this->recurseArg($directory, array($this, "runDir"));
        } else {
            $curdir = getcwd();
            chdir($this->phpci->buildPath);

            $phpunit = $this->phpci->findBinary('phpunit');

            $cmd = $phpunit . ' --tap %s "%s"';
            $success = $this->phpci->executeCommand($cmd, $this->args, $this->phpci->buildPath . $directory);
            chdir($curdir);
            return $success;
        }
    }
590969
public function getDir($directory)
    {
        $directory = str_replace('/', DS, $directory);
        if (strpos($directory, $this->getBaseDir()) === false || !file_exists($directory)) {
            $directory = $this->getBaseDir() . DS . ltrim($directory, DS);
        }
        return $directory;
    }
1175420
protected function createDirectory($directory)
    {
        $isCreated = file_exists($directory) || is_dir($directory) || mkdir($directory, 0777, true);
        
        if (!$isCreated)
            throw new RuntimeException('Cannot create directory ":dir" for generated classed', ['dir' => $directory]);
        
        return $this;
    }
504963
protected function _makeDirectory( $directory )
    {
        try
        {
            if ( !is_dir( $directory ) && !is_file( $directory ) && !is_link( $directory ) )
            {
                mkdir( $directory, 0755, true );
            }
        }
        catch ( \Exception $e )
        {
            $this->error( $e->getMessage() );
            die;
        }
    }
1305834
static function contents($directory) {
        if (!self::exists($directory)) return null;

        $dircontents = [];

        $contents = scandir($directory);

        foreach ($contents as $content) {
            if ($content != '.' && $content != '..') {
                array_push($dircontents, $content);
            }
        }

        return $dircontents;
    }
1287474
public function add_dir($directory)
	{
		foreach ((array) $directory as $dir)
		{
			if ( ! preg_match('|.+/$|', $dir))
			{
				$dir .= '/';
			}

			$dir_time = $this->_get_mod_time($dir);
			$this->_add_dir($dir, $dir_time['file_mtime'], $dir_time['file_mdate']);
		}
	}
525110
public function loadDirectory($directory) {
        $iterator = new DirectoryIterator($directory);
        foreach($iterator as $file) {
            if($file->isFile() && ends_with($file->getFilename(), '.php')) {
                require $directory . '/' . $file->getFilename();
            }
        }
    }