Skip to content

Commit e2e77a1

Browse files
Extract to method
1 parent e0a95b0 commit e2e77a1

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/Commands/Create.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ public function handle()
2121
?: config('db-snapshots.default_connection')
2222
?? config('database.default');
2323

24-
$snapshotName = !is_null($this->option('connection')) && is_null($this->argument('name'))
25-
? $this->option('connection')."_".Carbon::now()->format('Y-m-d_H-i-s')
26-
: $this->argument('name') ?? Carbon::now()->format('Y-m-d_H-i-s');
24+
$snapshotName = $this->getSnapshotName();
2725

2826
$compress = $this->option('compress') || config('db-snapshots.compress', false);
2927

@@ -51,4 +49,13 @@ public function handle()
5149

5250
$this->info("Snapshot `{$snapshotName}` created (size: {$size})");
5351
}
52+
53+
private function getSnapshotName(): string
54+
{
55+
if (!is_null($this->option('connection')) && is_null($this->argument('name'))) {
56+
return $this->option('connection'). "_". Carbon::now()->format('Y-m-d_H-i-s');
57+
}
58+
59+
return $this->argument('name') ?? Carbon::now()->format('Y-m-d_H-i-s');
60+
}
5461
}

0 commit comments

Comments
 (0)