Code Duplication    Length = 21-23 lines in 2 locations

src/Domain/Blog/MysqlPostRepository.php 2 locations

@@ 84-106 (lines=23) @@
81
            ->fetchValue($query, $bindings);
82
    }
83
84
    public function getActivePostsByTag($tag, $limit = null, $offset = 0)
85
    {
86
        $query = "
87
            SELECT `id`, `title`, `path`, `date`, `body`, `category`
88
            FROM `jpemeric_blog`.`post`
89
            INNER JOIN `jpemeric_blog`.`ptlink` ON `ptlink`.`post_id` = `post`.`id` AND
90
                                                   `ptlink`.`tag_id` = :tag_id
91
            WHERE `display` = :is_active";
92
        if ($limit != null) {
93
            $query .= "
94
            LIMIT {$offset}, {$limit}";
95
        }
96
97
        $bindings = [
98
            'tag_id'    => $tag,
99
            'is_active' => 1,
100
        ];
101
102
        return $this
103
            ->connections
104
            ->getRead()
105
            ->fetchAll($query, $bindings);
106
    }
107
108
    public function getActivePostsCountByTag($tag)
109
    {
@@ 127-147 (lines=21) @@
124
            ->fetchValue($query, $bindings);
125
    }
126
127
    public function getActivePostsByCategory($category, $limit = null, $offset = 0)
128
    {
129
        $query = "
130
            SELECT `id`, `title`, `path`, `date`, `body`, `category`
131
            FROM `jpemeric_blog`.`post`
132
            WHERE `category` = :category AND `display` = :is_active";
133
        if ($limit != null) {
134
            $query .= "
135
            LIMIT {$offset}, {$limit}";
136
        }
137
138
        $bindings = [
139
            'category'  => $category,
140
            'is_active' => 1,
141
        ];
142
143
        return $this
144
            ->connections
145
            ->getRead()
146
            ->fetchAll($query, $bindings);
147
    }
148
149
    public function getActivePostsCountByCategory($category)
150
    {