Code Duplication    Length = 19-21 lines in 2 locations

src/App/ResultDB.php 2 locations

@@ 184-202 (lines=19) @@
181
     * @param   Variable $var
182
     * @return  int|null
183
     */
184
    protected function variable_id(Variable $var) {
185
        $res = $this->builder()
186
            ->select("id")
187
            ->from($this->variable_table())
188
            ->where($this->builder()->expr()->andX
189
                ( "name = ?"
190
                , "meaning = ?"
191
                ))
192
            ->setParameter(0, $var->name())
193
            ->setParameter(1, $var->meaning())
194
            ->execute()
195
            ->fetch();
196
        if ($res) {
197
            return (int)$res["id"];
198
        }
199
        else {
200
            return null;
201
        }
202
    }
203
204
    protected function upsert_variable(Variable $var) {
205
        $var_id = $this->variable_id($var);
@@ 249-269 (lines=21) @@
246
     * @param   Violation   $violation
247
     * @return  int|null
248
     */
249
    protected function violation_id(Violation $violation) {
250
        $res = $this->builder()
251
            ->select("id")
252
            ->from($this->violation_table())
253
            ->where($this->builder()->expr()->andX
254
                ( "rule_id = ?"
255
                , "file = ?"
256
                , "line = ?"
257
                ))
258
            ->setParameter(0, $this->current_rule_id)
259
            ->setParameter(1, $violation->filename())
260
            ->setParameter(2, $violation->line())
261
            ->execute()
262
            ->fetch();
263
        if ($res) {
264
            return (int)$res["id"];
265
        }
266
        else {
267
            return null;
268
        }
269
    }
270
271
    // Names
272