Yaffs site version 1.1
[yaffs-website] / vendor / twig / twig / test / Twig / Tests / FilesystemHelper.php
1 <?php
2
3 /*
4  * This file is part of Twig.
5  *
6  * (c) Fabien Potencier
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 class Twig_Tests_FilesystemHelper
13 {
14     public static function removeDir($dir)
15     {
16         $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir, PHP_VERSION_ID < 50300 ? 0 : FilesystemIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST);
17         foreach ($iterator as $filename => $fileInfo) {
18             if ($iterator->isDot()) {
19                 continue;
20             }
21
22             if ($fileInfo->isDir()) {
23                 rmdir($filename);
24             } else {
25                 unlink($filename);
26             }
27         }
28         rmdir($dir);
29     }
30 }