Completed
Push — master ( c1b66d...b93db5 )
by Jacob
03:16
created

MysqlChangelogRepository::insertChange()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 30
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 30
rs 8.8571
cc 2
eloc 19
nc 2
nop 5
1
<?php
2
3
namespace Jacobemerick\Web\Domain\Stream\Changelog;
4
5
use Aura\Sql\ConnectionLocator;
6
7
class MysqlChangelogRepository implements ChangelogRepositoryInterface
8
{
9
10
    /** @var  ConnectionLocator */
11
    protected $connections;
12
13
    /**
14
     * @param ConnectonLocator $connections
15
     */
16
    public function __construct(ConnectionLocator $connections)
17
    {
18
        $this->connections = $connections;
19
    }
20
21
    /**
22
     * @param integer $limit
23
     * @param integer $offset
24
     *
25
     * @return array|false
26
     */
27
    public function getChanges($limit = null, $offset = 0)
28
    {
29
        $query = "
30
            SELECT `message`, `message_short`, `datetime`, `commit_link`
31
            FROM `jpemeric_stream`.`changelog`
32
            ORDER BY `datetime` DESC";
33
        if (!is_null($limit)) {
34
            $query .= "
35
            LIMIT {$offset}, {$limit}";
36
        }
37
38
        return $this
39
            ->connections
40
            ->getRead()
41
            ->fetchAll($query);
42
    }
43
}
44