Code Duplication    Length = 13-16 lines in 2 locations

src/Report/Queries.php 2 locations

@@ 90-105 (lines=16) @@
87
     * @param   string  $commit_hash
88
     * @return  int|null
89
     */
90
    public function last_run_for($commit_hash) {
91
        $b = $this->result_db->builder();
92
        $res = $b
93
            ->select("id")
94
            ->from("runs")
95
            ->where("commit_hash = ?")
96
            ->setParameter(0, $commit_hash)
97
            ->orderBy("id", "DESC")
98
            ->setMaxResults(1)
99
            ->execute()
100
            ->fetch();
101
        if ($res) {
102
            return (int)$res["id"];
103
        }
104
        throw new \RuntimeException("Result database contains no runs.");
105
    }
106
107
    /**
108
     * Get information about a run.
@@ 242-254 (lines=13) @@
239
     * @param   int $run
240
     * @return  int[]
241
     */
242
    public function analyzed_rules($run) {
243
        $b = $this->result_db->builder();
244
        $res = $b
245
            ->select("rrs.id")
246
            ->from("runs", "rs")
247
            ->innerJoin("rs", "rules", "rrs",
248
                "rs.id >= rrs.first_seen AND rs.id <= rrs.last_seen")
249
            ->where("rs.id = ?")
250
            ->setParameter(0, $run)
251
            ->execute()
252
            ->fetchAll();
253
        return array_map(function($r) { return $r["id"]; }, $res);
254
    }
255
256
    /**
257
     * Get information about a rule.