Passed
Pull Request — master (#4)
by Milan
01:27
created

Command::commandImport()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace PmgDev\DatabaseReplicator\Database\Postgres;
4
5
use PmgDev\DatabaseReplicator;
6
use PmgDev\DatabaseReplicator\Config;
7
use PmgDev\DatabaseReplicator\Source;
8
9
class Command extends DatabaseReplicator\Database\Command
10
{
11
	/** @var PgPhp */
12
	private $pgPhp;
13
14
	/** @var Psql */
15
	private $psql;
16
17
18
	public function __construct(PgPhp $pgPhp, Psql $psql)
19
	{
20
		$this->pgPhp = $pgPhp;
21
		$this->psql = $psql;
22
	}
23
24
25
	public function drop(string $database): void
26
	{
27
		$this->pgPhp->drop($database);
28
	}
29
30
31
	public function copy(Config $source, string $cloneDb): void
32
	{
33
		$this->pgPhp->copy($source, $cloneDb);
34
	}
35
36
37
	public function existsDatabase(string $database): bool
38
	{
39
		return $this->pgPhp->existsDatabase($database);
40
	}
41
42
43
	public function listDatabases(): iterable
44
	{
45
		return $this->pgPhp->listDatabases();
46
	}
47
48
49
	public function create(Config $config): void
50
	{
51
		$this->pgPhp->create($config);
52
	}
53
54
55
	protected function commandImport(Source\Files $filenames, Config $config): void
56
	{
57
		$this->psql->importFiles($filenames, $config);
58
	}
59
60
}
61