Completed
Push — master ( 4dd8bf...5dcaed )
by Filipe
07:48
created

AbstractRepository::getCollectionsMap()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
crap 2
1
<?php
2
3
/**
4
 * This file is part of slick/orm package
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Slick\Orm\Repository;
11
12
use Slick\Database\Adapter\AdapterInterface;
13
use Slick\Orm\Descriptor\EntityDescriptorInterface;
14
use Slick\Orm\Entity\CollectionsMap;
15
use Slick\Orm\Entity\CollectionsMapInterface;
16
use Slick\Orm\EntityMapperInterface;
17
18
/**
19
 * Abstract entity Repository
20
 *
21
 * @package Slick\Orm
22
 * @author  Filipe Silva <[email protected]>
23
 */
24
abstract class AbstractRepository
25
{
26
27
    /**
28
     * @var AdapterInterface
29
     */
30
    protected $adapter;
31
32
    /**
33
     * @var EntityDescriptorInterface
34
     */
35
    protected $entityDescriptor;
36
37
    /**
38
     * @var EntityMapperInterface
39
     */
40
    protected $entityMapper;
41
42
    /**
43
     * @var IdentityMapInterface
44
     */
45
    protected $identityMap;
46
47
    /**
48
     * @var CollectionsMapInterface;
49
     */
50
    protected $collectionsMap;
51
52
    /**
53
     * Sets the adapter for this statement
54
     *
55
     * @param AdapterInterface $adapter
56
     *
57
     * @return $this|self|AbstractRepository
58
     */
59 4
    public function setAdapter(AdapterInterface $adapter)
60
    {
61 4
        $this->adapter = $adapter;
62 4
        return $this;
63
    }
64
65
    /**
66
     * Retrieves the current adapter
67
     *
68
     * @return AdapterInterface
69
     */
70 4
    public function getAdapter()
71
    {
72 4
        return $this->adapter;
73
    }
74
75
    /**
76
     * Set the entity descriptor interface
77
     *
78
     * @param EntityDescriptorInterface $descriptor
79
     * @return $this|self|AbstractRepository
80
     */
81 8
    public function setEntityDescriptor(EntityDescriptorInterface $descriptor)
82
    {
83 8
        $this->entityDescriptor = $descriptor;
84 8
        return $this;
85
    }
86
87
    /**
88
     * Gets entity descriptor
89
     *
90
     * @return EntityDescriptorInterface
91
     */
92 4
    public function getEntityDescriptor()
93
    {
94 4
        return $this->entityDescriptor;
95
    }
96
97
    /**
98
     * @return EntityMapperInterface
99
     */
100 2
    public function getEntityMapper()
101
    {
102 2
        return $this->entityMapper;
103
    }
104
105
    /**
106
     * @param $entityMapper
107
     * @return $this
108
     */
109 4
    public function setEntityMapper($entityMapper)
110
    {
111 4
        $this->entityMapper = $entityMapper;
112 4
        return $this;
113
    }
114
115
    /**
116
     * Sets identity map for this repository
117
     *
118
     * @param IdentityMapInterface $map
119
     * @return $this|self|EntityRepository
120
     */
121 8
    public function setIdentityMap(IdentityMapInterface $map)
122
    {
123 8
        $this->identityMap = $map;
124 8
        return $this;
125
    }
126
127
    /**
128
     * Gets identity map for this repository
129
     *
130
     * @return IdentityMapInterface
131
     */
132 12
    public function getIdentityMap()
133
    {
134 12
        if (null == $this->identityMap) {
135 4
            $this->setIdentityMap(new IdentityMap());
136 4
        }
137 12
        return $this->identityMap;
138
    }
139
140
    /**
141
     * Gets the collections map for this repository
142
     *
143
     * @return CollectionsMapInterface
144
     */
145 2
    public function getCollectionsMap()
146
    {
147 2
        if (null == $this->collectionsMap) {
148 2
            $this->setCollectionsMap(new CollectionsMap());
149 2
        }
150 2
        return $this->collectionsMap;
151
    }
152
153
    /**
154
     * Sets the collections map
155
     *
156
     * @param CollectionsMapInterface $collectionsMap
157
     *
158
     * @return $this|self|EntityRepository
159
     */
160 2
    public function setCollectionsMap(CollectionsMapInterface $collectionsMap)
161
    {
162 2
        $this->collectionsMap = $collectionsMap;
163 2
        return $this;
164
    }
165
166
167
168
}