AsksForSnapshotName   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 6
c 1
b 0
f 0
dl 0
loc 11
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A askForSnapshotName() 0 9 1
1
<?php
2
3
namespace Spatie\DbSnapshots\Commands\Concerns;
4
5
use Spatie\DbSnapshots\Snapshot;
6
use Spatie\DbSnapshots\SnapshotRepository;
7
8
trait AsksForSnapshotName
9
{
10
    public function askForSnapshotName(): string
11
    {
12
        $snapShots = app(SnapshotRepository::class)->getAll();
13
14
        $names = $snapShots->map(function (Snapshot $snapshot) {
15
            return $snapshot->name;
16
        })->values()->toArray();
17
18
        return $this->choice('Which snapshot?', $names, 0);
0 ignored issues
show
Bug introduced by
It seems like choice() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

18
        return $this->/** @scrutinizer ignore-call */ choice('Which snapshot?', $names, 0);
Loading history...
19
    }
20
}
21