Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Washing
- * Última revisão: 29-08-17
- */
- class Washing {
- /**
- * Smarty
- */
- public function __construct(...$item) {
- if(empty($item)) {
- self::clean(getcwd());
- }
- else {
- foreach($item as $current) {
- self::list($current);
- }
- }
- }
- /**
- * List
- */
- private function list($item = false) {
- if(isset($item) && is_string($item)) {
- self::clean($item);
- }
- else if(isset($item) && is_array($item)) {
- foreach($item as $current) {
- self::clean($current);
- }
- }
- else {
- self::clean(getcwd());
- }
- }
- /**
- * Clean
- */
- private function clean($item) {
- if(file_exists($item) && is_file($item)) {
- unlink($item);
- }
- else {
- foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($item, FilesystemIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST) as $file) {
- $file->isFile() ? unlink($file->getPathname()) : rmdir($file->getPathname());
- }
- rmdir($item);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement