Total Complexity | 7 |
Total Lines | 34 |
Duplicated Lines | 0 % |
Coverage | 92.31% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | final class RelationProvider implements RelationProviderInterface |
||
16 | { |
||
17 | /** @var array<non-empty-string, RelationMap> */ |
||
|
|||
18 | private array $relMaps = []; |
||
19 | |||
20 | 7418 | public function __construct( |
|
21 | private ?ORMInterface $orm, |
||
22 | ) { |
||
23 | } |
||
24 | |||
25 | /** |
||
26 | * Get relation map associated with the given class. |
||
27 | */ |
||
28 | 6874 | public function getRelationMap(string $entity): RelationMap |
|
29 | { |
||
30 | 6874 | if (isset($this->relMaps[$entity])) { |
|
31 | 5396 | return $this->relMaps[$entity]; |
|
32 | } |
||
33 | 6874 | if ($this->orm === null) { |
|
34 | throw new ORMException('Relation Map is not prepared.'); |
||
35 | } |
||
36 | |||
37 | 6874 | return $this->relMaps[$entity] = RelationMap::build($this->orm, $entity); |
|
38 | } |
||
39 | |||
40 | 34 | public function prepareRelationMaps(): void |
|
49 | } |
||
50 | } |
||
51 |