Completed
Push — master ( 568319...1f7489 )
by Jacob
04:04
created

MysqlPostRepository::findByUri()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 5
Bugs 1 Features 1
Metric Value
c 5
b 1
f 1
dl 0
loc 15
rs 9.4286
cc 1
eloc 8
nc 1
nop 1
1
<?php
2
3
namespace Jacobemerick\Web\Domain\Blog;
4
5
use Aura\Sql\ConnectionLocator;
6
7
class MysqlPostRepository implements PostRepository
8
{
9
10
    /** @var  Aura\Sql\ConnectionLocator */
11
    protected $connections;
12
13
    /**
14
     * @param Aura\Sql\ConnectionLocator $connections
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 string $category
23
     * @param string $path
24
     *
25
     * @return array|false
26
     */
27
    public function findByPath($category, $path)
28
    {
29
        $query = "
30
            SELECT `id`, `title`, `path`, `date`, `body`, `category`
31
            FROM `jpemeric_blog`.`post`
32
            WHERE `path` = :path AND `category` = :category AND `display` = :is_active
33
            LIMIT 1";
34
        $bindings = array(
35
            'path'      => $path,
36
            'category'  => $category,
37
            'is_active' => 1,
38
        );
39
40
        return $this
41
            ->connections
42
            ->getRead()
43
            ->fetchOne($query, $bindings);
44
    }
45
}
46