Code Duplication    Length = 16-16 lines in 2 locations

src/Report/Queries.php 2 locations

@@ 44-59 (lines=16) @@
41
     * @param   string  $commit_hash
42
     * @return  int|null
43
     */
44
    public function last_run_for($commit_hash) {
45
        $b = $this->result_db->builder();
46
        $res = $b
47
            ->select("id")
48
            ->from("runs")
49
            ->where("commit_hash = ?")
50
            ->setParameter(0, $commit_hash)
51
            ->orderBy("id", "DESC")
52
            ->setMaxResults(1)
53
            ->execute()
54
            ->fetch();
55
        if ($res) {
56
            return (int)$res["id"];
57
        }
58
        throw new \RuntimeException("Result database contains no run for commit '$commit_hash'.");
59
    }
60
61
    /**
62
     * Get the id of the run before the given run.
@@ 67-82 (lines=16) @@
64
     * @param   int     $run
65
     * @return  int
66
     */
67
    public function run_before($run) {
68
        $b = $this->result_db->builder();
69
        $res = $b
70
            ->select("id")
71
            ->from("runs")
72
            ->where("id < ?")
73
            ->setParameter(0, $run)
74
            ->orderBy("id", "DESC")
75
            ->setMaxResults(1)
76
            ->execute();
77
        $res = $res->fetch();
78
        if ($res) {
79
            return (int)$res["id"];
80
        }
81
        throw new \RuntimeException("Result database contains no run before '$run'.");
82
    }
83
84
    /**
85
     * Get the id of the run before the given run that has another commit as the