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

MysqlChangelogRepository::getChangeByHash()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 8

Duplication

Lines 17
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 17
loc 17
rs 9.4285
cc 1
eloc 8
nc 1
nop 1
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