Code Duplication    Length = 16-18 lines in 2 locations

models/Challenge.php 2 locations

@@ 150-165 (lines=16) @@
147
        $this->opponent = (int)$clubID;
148
    }
149
150
    public function fetch()
151
    {
152
        $res = Yii::app()->db->createCommand()
153
            ->select('*')
154
            ->from('challenge')
155
            ->where('id=:id', [':id'=>$this->id])
156
            ->queryRow();
157
        if (!$res) {
158
            throw new CHttpException(404, 'A lekért verseny nem található.');
159
        }
160
161
        foreach ($res as $k => $v) {
162
            $this->$k = $v;
163
        }
164
        $this->active = !$this->winner;
165
    }
166
167
    public function fetchActiveChallenge()
168
    {
@@ 167-184 (lines=18) @@
164
        $this->active = !$this->winner;
165
    }
166
167
    public function fetchActiveChallenge()
168
    {
169
        $res = Yii::app()->db->createCommand()
170
            ->select('*')
171
            ->from('challenge')
172
            ->where('caller=:id OR opponent=:id', [':id'=>$this->opponent])
173
            ->order('created DESC')
174
            ->limit(1)
175
            ->queryRow();
176
        if (!$res) {
177
            return false;
178
        }
179
180
        foreach ($res as $k => $v) {
181
            $this->$k = $v;
182
        }
183
        $this->active = !$this->winner;
184
    }
185
186
    public function hasActiveChallenge($clubID)
187
    {