ExamAddModel   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 1
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 17
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A add() 0 14 1
1
<?php
2
3
namespace Egzaminer\Model;
4
5
use PDO;
6
7
class ExamAddModel extends AbstractModel
8
{
9
    public function add(array $post): int
10
    {
11
        $stmt = $this->db->prepare(
12
            'INSERT INTO exams (title, questions, threshold, group_id)
13
            VALUES (:title, :questions, :threshold, :group_id)'
14
        );
15
        $stmt->bindValue(':title', trim($post['title']));
16
        $stmt->bindValue(':questions', (int) $post['questions'], PDO::PARAM_INT);
17
        $stmt->bindValue(':threshold', (int) $post['threshold'], PDO::PARAM_INT);
18
        $stmt->bindValue(':group_id', (int) $post['group_id'], PDO::PARAM_INT);
19
        $stmt->execute();
20
21
        return $this->db->lastInsertId();
22
    }
23
}
24