Kahlan\Dir\Dir::remove PHP Метод

remove() публичный статический Метод

Removes one or many directories.
public static remove ( array | string $path, array $options = [] )
$path array | string Path or paths to scan.
$options array Scanning options. Possible values are: -`'followSymlinks'` _boolean_ : Follows Symlinks if `true`. -`'recursive'` _boolean_ : Scans recursively if `true`.
    public static function remove($path, $options = [])
    {
        $defaults = ['followSymlinks' => false, 'recursive' => true];
        $options += $defaults;
        $options['type'] = [];
        $options['skipDots'] = true;
        $options['leavesOnly'] = false;
        $options['iterator'] = RecursiveIteratorIterator::CHILD_FIRST;
        unset($options['include']);
        unset($options['exclude']);
        $paths = array_merge(static::scan($path, $options), (array) $path);
        foreach ($paths as $path) {
            is_dir($path) ? rmdir($path) : unlink($path);
        }
    }

Usage Example

Пример #1
0
            Dir::remove($this->temp);
        });
        it("clears the cache", function () {
            $this->interceptor->clearCache();
            expect(file_exists($this->customCachePath))->toBe(false);
        });
        it("bails out if the cache has already been cleared", function () {
            $this->interceptor->clearCache();
            $this->interceptor->clearCache();
            expect(file_exists($this->customCachePath))->toBe(false);
        });
    });
    describe("->watch()/unwatch()", function () {
        it("add some file to be watched", function () {
            $this->temp = Dir::tempnam(null, 'cache');
            touch($this->temp . DS . 'watched1.php');
            touch($this->temp . DS . 'watched2.php');
            $watched = [$this->temp . DS . 'watched1.php', $this->temp . DS . 'watched2.php'];
            $this->interceptor = Interceptor::patch(['cachePath' => $this->cachePath]);
            $this->interceptor->watch($this->temp . DS . 'watched1.php');
            expect($this->interceptor->watched())->toBe([$watched[0]]);
            $this->interceptor->watch($this->temp . DS . 'watched2.php');
            expect($this->interceptor->watched())->toBe($watched);
            $this->interceptor->unwatch($this->temp . DS . 'watched1.php');
            expect($this->interceptor->watched())->toBe([$watched[1]]);
            $this->interceptor->unwatch($this->temp . DS . 'watched2.php');
            expect($this->interceptor->watched())->toBe([]);
            Dir::remove($this->temp);
        });
    });
});
All Usage Examples Of Kahlan\Dir\Dir::remove