Prefix::database()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php declare(strict_types=1);
2
3
namespace PmgDev\DatabaseReplicator\Database;
4
5
use PmgDev\DatabaseReplicator\Config;
6
use PmgDev\DatabaseReplicator\Source\Hash;
7
8
class Prefix
9
{
10
	/** @var Config */
11
	private $config;
12
13
	/** @var Hash */
14
	private $sourceHash;
15
16
17
	public function __construct(Config $config, Hash $sourceHash)
18
	{
19
		$this->config = $config;
20
		$this->sourceHash = $sourceHash;
21
	}
22
23
24
	public function config(): Config
25
	{
26
		$config = clone $this->config;
27
		$config->database = $this->database();
28
		return $config;
29
	}
30
31
32
	public function database(): string
33
	{
34
		return $this->prefix() . $this->sourceHash->md5();
35
	}
36
37
38
	public function prefix(): string
39
	{
40
		return "_{$this->config->database}_";
41
	}
42
43
}
44