/** * Runs cleaner algorithm on the backupdir * * @param Backupdir $backupDir * @return Array List of backupdirs for cleanning * @author : Rafał Trójniak rafal@trojniak.net */ public function clean(\Backupdir $backupDir) { $backups=$backupDir->getBackups(); $i=$this->count; while($i and count($backups)){ array_pop($backups); $i--; } return $backups; }
/** * Runs cleaner algorithm on the backupdir * * @param Backupdir $backupDir * @return Array List of backupdirs for cleanning * @author : Rafał Trójniak rafal@trojniak.net */ public function clean(\Backupdir $backupDir) { $newest=$backupDir->getNewestBackup(); if(is_null($newest)){ return array(); } // Get minimal date from the backup $limit = clone $newest->getCreation(); $limit->sub($this->age); $toClean=array(); foreach($backupDir->getBackups() as $cur){ $stamp=$cur->getCreation(); if( $stamp->getTimestamp()< $limit->getTimestamp()) { $toClean[]=$cur; } } return $toClean; }