Completed
Push — master ( 077f63...ceb768 )
by Andrii
02:53
created

EntityManager   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 21
ccs 0
cts 8
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getRepository() 0 16 4
1
<?php
2
3
namespace hiapi\components;
4
5
use Yii;
6
7
class EntityManager extends \yii\base\Component
8
{
9
    public $repositories = [];
10
11
    public function getRepository($entityClass)
12
    {
13
        if (is_object($entityClass)) {
14
            $entityClass = get_class($entityClass);
15
        }
16
17
        if (!isset($this->repositories[$entityClass])) {
18
            throw new \Exception("no repository defined for: $entityClass");
19
        }
20
21
        if (!is_object($this->repositories[$entityClass])) {
22
            $this->repositories[$entityClass] = Yii::createObject($this->repositories[$entityClass]);
23
        }
24
25
        return $this->repositories[$entityClass];
26
    }
27
}
28