Code Duplication    Length = 16-16 lines in 2 locations

src/Analysis/Result.php 2 locations

@@ 60-75 (lines=16) @@
57
     * @param   Def\Rules\Rule  $rule
58
     * @return  Violation[]
59
     */
60
    public function violations_of(Rule $rule) {
61
        $r = $rule->pprint();
62
        if (array_key_exists($r, $this->by_rule_cache)) {
63
            return $this->by_rule_cache[$r];
64
        }
65
66
        $vs = array();
67
        foreach ($this->violations as $v) {
68
            if ($v->rule() == $rule) {
69
                $vs[] = $v;
70
            }
71
        }
72
73
        $this->by_rule_cache[$r] = $vs;
74
        return $vs;
75
    }
76
77
    /**
78
     * @param   string          $filename
@@ 81-96 (lines=16) @@
78
     * @param   string          $filename
79
     * @return  Violation[]
80
     */
81
    public function violations_in($filename) {
82
        assert('is_string($filename)');
83
        if (array_key_exists($filename, $this->by_filename_cache)) {
84
            return $this->by_filename_cache[$filename];
85
        }
86
87
        $vs = array();
88
        foreach ($this->violations as $v) {
89
            if ($v->filename() == $filename) {
90
                $vs[] = $v;
91
            }
92
        }
93
94
        $this->by_filename_cache[$filename] = $vs;
95
        return $vs;
96
    }
97
}
98