Completed
Push — master ( ac011d...56c397 )
by Mikołaj
03:19
created

ExamEditModel::edit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 14
Ratio 100 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 14
loc 14
rs 9.4285
cc 1
eloc 8
nc 1
nop 2
1
<?php
2
3
namespace Egzaminer\Model;
4
5
use PDO;
6
7 View Code Duplication
class ExamEditModel extends AbstractModel
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
8
{
9
    /**
10
     * Edit exam.
11
     *
12
     * @param int   $examID
13
     * @param array $post
14
     *
15
     * @return bool
16
     */
17
    public function edit($examID, $post)
18
    {
19
        $stmt = $this->db->prepare('UPDATE exams SET title = :title,
20
            questions = :questions, threshold = :threshold, group_id = :group_id
21
            WHERE id = :id'
22
        );
23
        $stmt->bindValue(':title', trim($post['title']), PDO::PARAM_STR);
24
        $stmt->bindValue(':questions', $post['questions'], PDO::PARAM_INT);
25
        $stmt->bindValue(':threshold', $post['threshold'], PDO::PARAM_INT);
26
        $stmt->bindValue(':group_id', $post['group_id'], PDO::PARAM_INT);
27
        $stmt->bindValue(':id', $examID, PDO::PARAM_INT);
28
29
        return $stmt->execute();
30
    }
31
}
32