Completed
Push — master ( c330e2...cf0c7a )
by Jacob
03:58
created

MysqlYouTubeRepository::getYouTubeByVideoId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 16
rs 9.4286
c 1
b 0
f 1
cc 1
eloc 8
nc 1
nop 1
1
<?php
2
3
namespace Jacobemerick\Web\Domain\Stream\YouTube;
4
5
use Aura\Sql\ConnectionLocator;
6
7
class MysqlYouTubeRepository implements YouTubeRepositoryInterface
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 $id
23
     *
24
     * @return array|false
25
     */
26
    public function getYouTubeById($id)
27
    {
28
        $query = "
29
            SELECT *
30
            FROM `jpemeric_stream`.`youtube`
31
            WHERE `id` = :id
32
            LIMIT 1";
33
        $bindings = [
34
            'id' => $id,
35
        ];
36
37
        return $this
38
            ->connections
39
            ->getRead()
40
            ->fetchOne($query, $bindings);
41
    }
42
43
    /**
44
     * @param string $title
0 ignored issues
show
Bug introduced by
There is no parameter named $title. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
45
     *
46
     * @return array|false
47
     */
48
    public function getYouTubeByVideoId($videoId)
49
    {
50
        $query = "
51
            SELECT *
52
            FROM `jpemeric_stream`.`youtube`
53
            WHERE `video_id` = :video_id
54
            LIMIT 1";
55
        $bindings = [
56
            'video_id' => $videoId,
57
        ];
58
59
        return $this
60
            ->connections
61
            ->getRead()
62
            ->fetchOne($query, $bindings);
63
    }
64
65
    /**
66
     * @return array|false
67
     */
68
    public function getUnmappedYouTubes()
69
    {
70
        $query = "
71
            SELECT `id`, `date`
72
            FROM `jpemeric_stream`.`youtube`
73
            LEFT JOIN `jpemeric_stream`.`post`
74
            ON `post`.`type_id` = `youtube`.`id` AND `post`.`id` IS NULL";
75
76
        return $this
77
            ->connections
78
            ->getRead()
79
            ->fetchAll($query);
80
    }
81
}
82