Get the diff in days for a given file and carbon date
public static diffInDays ( $log, Carbon\Carbon $date ) : integer | ||
$log | ||
$date | Carbon\Carbon | |
리턴 | integer |
/** * @test */ public function it_gets_the_diff() { $today = Carbon::today(); $logDate = Carbon::today()->subDays(10); $log = "laravel-{$logDate->toDateString()}.log"; $this->assertSame(10, LogUtil::diffInDays($log, $today)); }
private function remoteCleanUp() { $this->logger->info("Starting remote clean up"); $logs = $this->remoteRepo->getCompressed(); foreach ($logs as $log) { $days = LogUtil::diffInDays($log, $this->today); $this->logger->info("{$log} is {$days} day(s) old"); if ($days > $this->remoteRetentionDaysCalculated) { $this->logger->info("Deleting {$log}"); $this->remoteRepo->delete($log); } else { $this->logger->info("Keeping {$log}"); } } }