Clockwork\Support\Lumen\ClockworkCleanCommand::fire PHP Method

fire() public method

Execute the console command.
public fire ( ) : void
return void
    public function fire()
    {
        $data_dir = storage_path() . '/clockwork';
        $this->info('Cleaning ' . $data_dir . ' ...');
        $files = glob($data_dir . '/*.json');
        if (!$files || !count($files)) {
            $this->info('Nothing to clean up.');
            return;
        }
        $max_age = $this->option('age') ? time() - $this->option('age') * 60 * 60 : null;
        $count = 0;
        foreach ($files as $file) {
            $tokens = explode('.', basename($file));
            if ($max_age && $tokens[0] > $max_age) {
                continue;
            }
            unlink($file);
            $count++;
        }
        $this->info($count . ' files removed.');
    }