Code Duplication    Length = 19-21 lines in 2 locations

src/Report/ResultDB.php 2 locations

@@ 194-212 (lines=19) @@
191
     * @param   Variable $var
192
     * @return  int|null
193
     */
194
    protected function variable_id(Variable $var) {
195
        $res = $this->builder()
196
            ->select("id")
197
            ->from("variables")
198
            ->where($this->builder()->expr()->andX
199
                ( "name = ?"
200
                , "meaning = ?"
201
                ))
202
            ->setParameter(0, $var->name())
203
            ->setParameter(1, $var->meaning())
204
            ->execute()
205
            ->fetch();
206
        if ($res) {
207
            return (int)$res["id"];
208
        }
209
        else {
210
            return null;
211
        }
212
    }
213
214
    protected function upsert_variable(Variable $var) {
215
        $var_id = $this->variable_id($var);
@@ 259-279 (lines=21) @@
256
     * @param   Violation   $violation
257
     * @return  int|null
258
     */
259
    protected function violation_id(Violation $violation) {
260
        $res = $this->builder()
261
            ->select("id")
262
            ->from("violations")
263
            ->where($this->builder()->expr()->andX
264
                ( "rule_id = ?"
265
                , "file = ?"
266
                , "line = ?"
267
                ))
268
            ->setParameter(0, $this->current_rule_id)
269
            ->setParameter(1, $violation->filename())
270
            ->setParameter(2, $violation->line())
271
            ->execute()
272
            ->fetch();
273
        if ($res) {
274
            return (int)$res["id"];
275
        }
276
        else {
277
            return null;
278
        }
279
    }
280
281
    // Creation of database.
282