CommonModuleBaseService   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 30
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getMasterInstance() 0 6 1
A getDefaultInstance() 0 6 1
A __construct() 0 6 1
1
<?php
2
namespace Ridibooks\Platform\Common\Base;
3
4
use Ridibooks\Library\DB\GnfConnectionProvider;
5
use Ridibooks\Platform\Common\Constant\PlatformConnectionGroup;
6
7
abstract class CommonModuleBaseService
8
{
9
	/** @var \Gnf\db\base */
10
	protected $db;
11
	/** @var string */
12
	protected $connection_group_name;
13
14
	/** @return static */
15
	public static function getMasterInstance()
16
	{
17
		$class_name = get_called_class();
18
19
		return new $class_name(PlatformConnectionGroup::COMMON_MODULE_READ_MASTER);
20
	}
21
22
	/** @return static */
23
	public static function getDefaultInstance()
24
	{
25
		$class_name = get_called_class();
26
27
		return new $class_name(PlatformConnectionGroup::COMMON_MODULE_READ);
28
	}
29
30
	public function __construct(string $connection_group_name)
31
	{
32
		$this->connection_group_name = $connection_group_name;
33
34
		$this->db = GnfConnectionProvider::getConnection($connection_group_name);
35
	}
36
}
37