Completed
Push — master ( ec3686...b09171 )
by Jacob
06:23
created

MysqlSeriesRepository::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 4
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Jacobemerick\Web\Domain\Blog;
4
5
use Aura\Sql\ConnectionLocator;
6
7 View Code Duplication
class MysqlSeriesRepository implements IntroductionRepository
0 ignored issues
show
Bug introduced by
There is one abstract method findByType in this class; you could implement it, or declare this class as abstract.
Loading history...
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...
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
0 ignored issues
show
Bug introduced by
The method connections() does not seem to exist on object<Jacobemerick\Web\...\MysqlSeriesRepository>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
47
            ->connections()
48
            ->getRead()
49
            ->fetchAll($query, $bindings);
50
    }
51
}
52