Completed
Push — master ( 814e9e...2525ff )
by Filipe
03:26
created

AbstractRepository::getAdapter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
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\EntityMapperInterface;
15
16
/**
17
 * Abstract entity Repository
18
 *
19
 * @package Slick\Orm
20
 * @author  Filipe Silva <[email protected]>
21
 */
22
abstract class AbstractRepository
23
{
24
25
    /**
26
     * @var AdapterInterface
27
     */
28
    protected $adapter;
29
30
    /**
31
     * @var EntityDescriptorInterface
32
     */
33
    protected $entityDescriptor;
34
35
    /**
36
     * @var EntityMapperInterface
37
     */
38
    protected $entityMapper;
39
40
    /**
41
     * @var IdentityMapInterface
42
     */
43
    protected $identityMap;
44
45
    /**
46
     * Sets the adapter for this statement
47
     *
48
     * @param AdapterInterface $adapter
49
     *
50
     * @return $this|self|AbstractRepository
51
     */
52
    public function setAdapter(AdapterInterface $adapter)
53
    {
54
        $this->adapter = $adapter;
55
        return $this;
56
    }
57
58
    /**
59
     * Retrieves the current adapter
60
     *
61
     * @return AdapterInterface
62
     */
63
    public function getAdapter()
64
    {
65
        return $this->adapter;
66
    }
67
68
    /**
69
     * Set the entity descriptor interface
70
     *
71
     * @param EntityDescriptorInterface $descriptor
72
     * @return $this|self|AbstractRepository
73
     */
74
    public function setEntityDescriptor(EntityDescriptorInterface $descriptor)
75
    {
76
        $this->entityDescriptor = $descriptor;
77
        return $this;
78
    }
79
80
    /**
81
     * Gets entity descriptor
82
     *
83
     * @return EntityDescriptorInterface
84
     */
85
    public function getEntityDescriptor()
86
    {
87
        return $this->entityDescriptor;
88
    }
89
90
    /**
91
     * @return EntityMapperInterface
92
     */
93
    public function getEntityMapper()
94
    {
95
        return $this->entityMapper;
96
    }
97
98
    /**
99
     * @param $entityMapper
100
     * @return $this
101
     */
102
    public function setEntityMapper($entityMapper)
103
    {
104
        $this->entityMapper = $entityMapper;
105
        return $this;
106
    }
107
108
    /**
109
     * Sets identity map for this repository
110
     *
111
     * @param IdentityMapInterface $map
112
     * @return $this|self|EntityRepository
113
     */
114
    public function setIdentityMap(IdentityMapInterface $map)
115
    {
116
        $this->identityMap = $map;
117
        return $this;
118
    }
119
120
    /**
121
     * Gets identity map for this repository
122
     *
123
     * @return IdentityMapInterface
124
     */
125
    protected function getIdentityMap()
126
    {
127
        if (null == $this->identityMap) {
128
            $this->setIdentityMap(new IdentityMap());
129
        }
130
        return $this->identityMap;
131
    }
132
133
}