Completed
Push — master ( 34318d...75f992 )
by Jacob
03:35
created

MysqlSeriesRepository::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Jacobemerick\Web\Domain\Blog\Series;
4
5
use Aura\Sql\ConnectionLocator;
6
7
class MysqlSeriesRepository implements SeriesRepositoryInterface
8
{
9
10
    /** @var  Aura\Sql\ConnectionLocator */
11
    protected $connections;
12
13
    /**
14
     * @param Aura\Sql\ConnectionLocator
15
     */
16
    public function __construct(ConnectionLocator $connections)
17
    {
18
        $this->connections = $connections;
0 ignored issues
show
Documentation Bug introduced by
It seems like $connections of type object<Aura\Sql\ConnectionLocator> is incompatible with the declared type object<Jacobemerick\Web\...\Sql\ConnectionLocator> of property $connections.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
19
    }
20
21
    /**
22
     * @param integer $post
23
     *
24
     * @return array|false
25
     */
26
    public function getSeriesForPost($post)
27
    {
28
        $query = "
29
            SELECT `series`.`title` AS `series_title`, `series`.`description` AS `series_descriptions`,
30
                   `post.id` AS `post`, `post`.`title`, `post`.`category`, `post`.`path`
31
            FROM `jpemeric_blog`.`series`
32
            INNER JOIN `jpemeric_blog`.`series_post` ON `series_post`.`series` = `series.`id`
33
            INNER JOIN `jpemeric_blog`.`post` ON `post`.`id` = `series_post`.`post` AND
34
                                                 `post`.`display` = :is_active
35
            WHERE `series`.`id` = (
36
                SELECT `series`
37
                FROM `jpemeric_blog`.`series_post`
38
                WHERE `post` = :lookup_post
39
                LIMIT 1)
40
            ORDER BY `series_post`.`order`";
41
        $bindings = [
42
            'is_active'   => 1,
43
            'lookup_post' => $post,
44
        ];
45
46
        return $this
47
            ->connections
48
            ->getRead()
49
            ->fetchAll($query, $bindings);
50
    }
51
}
52