FactoryMap   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 45
c 0
b 0
f 0
wmc 4
lcom 1
cbo 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A addFactory() 0 4 1
A hasFactory() 0 4 1
A getFactory() 0 4 1
1
<?php
2
3
namespace Isolate\Framework\PersistenceContext\Transaction;
4
5
use Isolate\PersistenceContext\Name;
6
use Isolate\PersistenceContext\Transaction\Factory;
7
8
/**
9
 * @api
10
 */
11
final class FactoryMap
12
{
13
    /**
14
     * @var array|Factory
15
     */
16
    private $factories;
17
18
    public function __construct()
19
    {
20
        $this->factories = [];
21
    }
22
23
    /**
24
     * @param Factory $transactionFactory
25
     * @param Name $contextName
26
     * 
27
     * @api
28
     */
29
    public function addFactory(Name $contextName, Factory $transactionFactory)
30
    {
31
        $this->factories[(string) $contextName] = $transactionFactory;
32
    }
33
34
    /**
35
     * @param Name $contextName
36
     * @return bool
37
     * 
38
     * @api
39
     */
40
    public function hasFactory(Name $contextName)
41
    {
42
        return array_key_exists((string) $contextName, $this->factories);
43
    }
44
45
    /**
46
     * @param Name $contextName
47
     * @return Factory
48
     * 
49
     * @api
50
     */
51
    public function getFactory(Name $contextName)
52
    {
53
        return $this->factories[(string) $contextName];
54
    }
55
}
56