Yii2Adapter   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 23
ccs 0
cts 14
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
A getConfig() 0 10 2
1
<?php
2
3
/**
4
 * This software package is licensed under `AGPL, Commercial` license[s].
5
 *
6
 * @package maslosoft/embedi
7
 * @license AGPL, Commercial
8
 *
9
 * @copyright Copyright (c) Peter Maselkowski <[email protected]>
10
 *
11
 */
12
13
namespace Maslosoft\EmbeDi\Adapters;
14
15
use Exception;
16
use Maslosoft\EmbeDi\EmbeDi;
17
use Yii;
18
19
/**
20
 * Yii2Adapter
21
 *
22
 * @author Piotr Maselkowski <pmaselkowski at gmail.com>
23
 */
24
class Yii2Adapter
25
{
26
27
	public function __construct()
28
	{
29
		if (!class_exists('Yii', false))
30
		{
31
			throw new Exception(sprintf('Adapter `%s` requires `Yii`', __CLASS__));
32
		}
33
	}
34
35
	public function getConfig($class, $instanceId)
0 ignored issues
show
Unused Code introduced by
The parameter $class is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
36
	{
37
		/**
38
		 * TODO Figure out if there is some better way to obtain config
39
		 */
40
		if (Yii::$app->has($instanceId))
41
		{
42
			return (new EmbeDi())->export(Yii::$app->get($instanceId));
43
		}
44
	}
45
46
}
47