Failed Conditions
Push — 177-support-modelshow ( 9991ed...1129c4 )
by Bas
09:54
created

DatabaseTruncation::migrateFreshUsing()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 10
nc 1
nop 0
dl 0
loc 17
rs 9.9332
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LaravelFreelancerNL\Aranguent\Testing;
6
7
use Illuminate\Foundation\Testing\DatabaseTruncation as IlluminateDatabaseTruncation;
8
use LaravelFreelancerNL\Aranguent\Testing\Concerns\CanConfigureMigrationCommands;
9
10
trait DatabaseTruncation
11
{
12
    use IlluminateDatabaseTruncation;
13
    use CanConfigureMigrationCommands;
14
15
    /**
16
     * The parameters that should be used when running "migrate:fresh".
17
     *
18
     * Duplicate code because CanConfigureMigrationCommands has a conflict otherwise.
19
     *
20
     * @return array
21
     */
22
    protected function migrateFreshUsing()
23
    {
24
        $seeder = $this->seeder();
25
26
        $results =  array_merge(
27
            [
28
                '--drop-analyzers' => $this->shouldDropAnalyzers(),
29
                '--drop-graphs' => $this->shouldDropGraphs(),
30
                '--drop-views' => $this->shouldDropViews(),
31
                '--drop-types' => $this->shouldDropTypes(),
32
                '--drop-all' => $this->shouldDropAll(),
33
            ],
34
            $seeder ? ['--seeder' => $seeder] : ['--seed' => $this->shouldSeed()],
35
            $this->setMigrationPaths(),
36
        );
37
38
        return $results;
39
    }
40
41
    /**
42
     * Determine if a table exists in the given list, with or without its schema.
43
     */
44
    protected function tableExistsIn(array $table, array $tables): bool
45
    {
46
        return isset($table['schema'])
47
            ? ! empty(array_intersect([$table['name'], $table['schema'] . '.' . $table['name']], $tables))
48
            : in_array($table['name'], $tables);
49
    }
50
}
51