Kahlan\Dir\Dir::_copy PHP Method

_copy() protected static method

Copies a directory.
protected static _copy ( string $path, string $dest, array $options ) : array
$path string Source directory.
$dest string Destination directory.
$options array Scanning options. Possible values are: -`'mode'` _integer_ : Mode used for directory creation. -`'childrenOnly'` _boolean_ : Excludes parent directory if `true`. -`'followSymlinks'` _boolean_ : Follows Symlinks if `true`. -`'recursive'` _boolean_ : Scans recursively if `true`. -`'include'` _string|array_: An array of includes. -`'exclude'` _string|array_: An array of excludes.
return array
    protected static function _copy($path, $dest, $options)
    {
        $ds = DIRECTORY_SEPARATOR;
        $root = $options['childrenOnly'] ? $path : dirname($path);
        $dest = rtrim($dest, $ds);
        $paths = static::scan($path, $options);
        foreach ($paths as $path) {
            $target = preg_replace('~^' . preg_quote(rtrim($root, $ds)) . '~', '', $path);
            $isDir = is_dir($path);
            $dirname = $dest . $ds . ltrim($isDir ? $target : dirname($target), $ds);
            if (!file_exists($dirname)) {
                mkdir($dirname, $options['mode'], true);
            }
            if (!$isDir) {
                copy($path, $dest . $ds . ltrim($target, $ds));
            }
        }
    }