Prefix   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A prefix() 0 3 1
A config() 0 5 1
A __construct() 0 4 1
A database() 0 3 1
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