Code Duplication    Length = 16-32 lines in 6 locations

src/Domain/Blog/Post/MysqlPostRepository.php 1 location

@@ 166-197 (lines=32) @@
163
            ->fetchValue($query, $bindings);
164
    }
165
166
    public function getActivePostsByRelatedTags($post, $limit = 4)
167
    {
168
        $query = "
169
            SELECT `id`, `title`, `path`, `date`, `body`, `category`, COUNT(1) AS `count`
170
            FROM `jpemeric_blog`.`post`
171
            INNER JOIN `jpemeric_blog`.`ptlink` ON `ptlink`.`post_id` = `post`.`id` AND
172
                                                   `ptlink`.`tag_id` IN (
173
                SELECT `id`
174
                FROM `jpemeric_blog`.`tag`
175
                INNER JOIN `jpemeric_blog`.`ptlink` ON `ptlink`.`tag_id` = `tag`.`id` AND
176
                                                       `ptlink`.`post_id` = :post)
177
            WHERE `id` <> :post AND `id` NOT IN (
178
                SELECT `post`
179
                FROM `jpemeric_blog`.`series_post`
180
                WHERE `id` = (
181
                    SELECT `series`
182
                    FROM `jpemeric_blog`.`series_post`
183
                    WHERE `post` = :post
184
                )) AND `display` = :is_active
185
            GROUP BY `id`
186
            ORDER BY `count` DESC
187
            LIMIT {$limit}";
188
        $bindings = [
189
            'post'      => $post,
190
            'is_active' => 1,
191
        ];
192
193
        return $this
194
            ->connections
195
            ->getRead()
196
            ->fetchAll($query, $bindings);
197
    }
198
}
199

src/Domain/Blog/Tag/MysqlTagRepository.php 2 locations

@@ 56-73 (lines=18) @@
53
            ->fetchAll($query);
54
    }
55
56
    public function getTagCloud()
57
    {
58
        $query = "
59
            SELECT COUNT(1) AS `count`, `tag`
60
            FROM `jpemeric_blog`.`tag`
61
            INNER JOIN `jpemeric_blog`.`ptlink` ON `ptlink`.`tag_id` = `tag`.`id`
62
            INNER JOIN `jpemeric_blog`.`post` ON `post`.`id` = `ptlink`.`post_id` AND
63
                                                 `post`.`display` = :is_active
64
            GROUP BY `tag`";
65
        $bindings = [
66
            'is_active' => 1,
67
        ];
68
69
        return $this
70
            ->connections
71
            ->getRead()
72
            ->fetchAll($query, $bindings);
73
    }
74
75
    public function getTagsForPost($post)
76
    {
@@ 75-90 (lines=16) @@
72
            ->fetchAll($query, $bindings);
73
    }
74
75
    public function getTagsForPost($post)
76
    {
77
        $query = "
78
            SELECT `tag`.*
79
            FROM `jpemeric_blog`.`tag`
80
            INNER JOIN `jpemeric_blog`.`ptlink` ON `ptlink`.`tag_id` AND `post_id` = :post
81
            ORDER BY `tag`";
82
        $bindings = [
83
            'post' => $post,
84
        ];
85
86
        return $this
87
            ->connections
88
            ->getRead()
89
            ->fetchAll($query, $bindings);
90
    }
91
}
92

src/Domain/Stream/Twitter/MysqlTwitterRepository.php 1 location

@@ 68-84 (lines=17) @@
65
     *
66
     * @return array|false
67
     */
68
    public function getTwitterByFields(DateTime $date, $text)
69
    {
70
        $query = "
71
            SELECT *
72
            FROM `jpemeric_stream`.`twitter`
73
            WHERE `date` = :date AND `text` = :text
74
            LIMIT 1";
75
        $bindings = [
76
            'date' => $date->format('Y-m-d H:i:s'),
77
            'text' => $text,
78
        ];
79
80
        return $this
81
            ->connections
82
            ->getRead()
83
            ->fetchOne($query, $bindings);
84
    }
85
86
    /**
87
     * @return array|false

src/Domain/Stream/Blog/MysqlBlogRepository.php 1 location

@@ 44-59 (lines=16) @@
41
            ->fetchOne($query, $bindings);
42
    }
43
44
    public function getBlogByPermalink($permalink)
45
    {
46
        $query = "
47
            SELECT *
48
            FROM `jpemeric_stream`.`blog2`
49
            WHERE `permalink` = :permalink
50
            LIMIT 1";
51
        $bindings = [
52
            'permalink' => $permalink,
53
        ];
54
55
        return $this
56
            ->connections
57
            ->getRead()
58
            ->fetchOne($query, $bindings);
59
    }
60
61
    /**
62
     * @param string $title

src/Domain/Stream/BlogComment/MysqlBlogCommentRepository.php 1 location

@@ 50-66 (lines=17) @@
47
     *
48
     * @return array|false
49
     */
50
    public function getBlogCommentByPermalink($permalink)
51
    {
52
        $query = "
53
            SELECT *
54
            FROM `jpemeric_stream`.`blog_comment`
55
            WHERE `permalink` = :permalink
56
            LIMIT 1";
57
58
        $bindings = [
59
            'permalink' => $permalink,
60
        ];
61
62
        return $this
63
            ->connections
64
            ->getRead()
65
            ->fetchOne($query, $bindings);
66
    }
67
68
    public function insertBlogComment($permalink, DateTime $datetime, array $metadata)
69
    {