Completed
Push — master ( 313f20...c23fe9 )
by Tim
9s
created

AbstractRepository::setSqlStatementRepository()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 4
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
/**
4
 * TechDivision\Import\Repositories\AbstractRepository
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @copyright 2016 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/techdivision/import
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Repositories;
22
23
use TechDivision\Import\Connection\ConnectionInterface;
24
25
/**
26
 * An abstract respository implementation.
27
 *
28
 * @author    Tim Wagner <[email protected]>
29
 * @copyright 2016 TechDivision GmbH <[email protected]>
30
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
31
 * @link      https://github.com/techdivision/import
32
 * @link      http://www.techdivision.com
33
 */
34 View Code Duplication
abstract class AbstractRepository implements RepositoryInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
35
{
36
37
    /**
38
     * The connection instance.
39
     * .
40
     * @var \TechDivision\Import\Connection\ConnectionInterface;
41
     */
42
    protected $connection;
43
44
    /**
45
     * The repository instance with the SQL statements to use.
46
     *
47
     * @var \TechDivision\Import\Repositories\SqlStatementRepositoryInterface
48
     */
49
    protected $sqlStatementRepository;
50
51
    /**
52
     * Initialize the repository with the passed connection and utility class name.
53
     * .
54
     * @param \TechDivision\Import\Connection\ConnectionInterface               $connection             The connection instance
55
     * @param \TechDivision\Import\Repositories\SqlStatementRepositoryInterface $sqlStatementRepository The SQL repository instance
56
     */
57
    public function __construct(
58
        ConnectionInterface $connection,
59
        SqlStatementRepositoryInterface $sqlStatementRepository
60
    ) {
61
62
        // set the passed instances
63
        $this->setConnection($connection);
64
        $this->setSqlStatementRepository($sqlStatementRepository);
65
66
        // initialize the instance
67
        $this->init();
68
    }
69
70
    /**
71
     * Set's the connection to use.
72
     * .
73
     * @param \TechDivision\Import\Connection\ConnectionInterface $connection The connection instance
74
     *
75
     * @return void
76
     */
77
    public function setConnection(ConnectionInterface $connection)
78
    {
79
        $this->connection = $connection;
80
    }
81
82
    /**
83
     * Return's the connection to use.
84
     *
85
     * @return \TechDivision\Import\Connection\ConnectionInterface The connection instance
86
     */
87
    public function getConnection()
88
    {
89
        return $this->connection;
90
    }
91
92
    /**
93
     * Set's the repository instance with the SQL statements to use.
94
     *
95
     * @param \TechDivision\Import\Repositories\SqlStatementRepositoryInterface $sqlStatementRepository The repository instance
96
     *
97
     * @return void
98
     */
99
    public function setSqlStatementRepository(SqlStatementRepositoryInterface $sqlStatementRepository)
100
    {
101
        $this->sqlStatementRepository = $sqlStatementRepository;
102
    }
103
104
    /**
105
     * Return's the repository instance with the SQL statements to use.
106
     *
107
     * @return \TechDivision\Import\Repositories\SqlStatementRepositoryInterface The repository instance
108
     */
109
    public function getSqlStatementRepository()
110
    {
111
        return $this->sqlStatementRepository;
112
    }
113
114
    /**
115
     * Load's the SQL statement with the passed ID from the SQL repository.
116
     *
117
     * @param string $id The ID of the SQL statement to load
118
     *
119
     * @return string The SQL statement with the passed ID
120
     */
121
    public function loadStatement($id)
122
    {
123
        return $this->getSqlStatementRepository()->load($id);
124
    }
125
}
126