src/Service/pdfService.php
public function cleanFiles($dir, $seconds)
    {
        $currentTime = time();
        $dirHandle=opendir($dir);
        while($file = readdir($dirHandle))
        {
            if(substr($file,0,3) == 'tmp' && substr($file,-4) == '.pdf')
            {
                $path = $dir.'/'.$file;
                if($currentTime - filemtime($path) > $seconds)
                    unlink($path);
            }
        }
        closedir($dirHandle);
    }
public function cleanFiles($dir, $seconds)
    {
        $currentTime = time();
        $dirHandle=opendir($dir);
        while($file = readdir($dirHandle))
        {
            if(substr($file,0,3) == 'tmp' && substr($file,-4) == '.pdf')
            {
                $path = $dir.'/'.$file;
                if($currentTime - filemtime($path) > $seconds)
                    unlink($path);
            }
        }
        closedir($dirHandle);
    }
Delete (temporary) files on specified directory

@param string $dir filly directori name
@param number $seconds