Completed
Push — master ( cceadc...3df73a )
by Mikołaj
04:41
created

AddModel   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A add() 0 18 1
1
<?php
2
3
namespace Rudolf\Modules\Users\One\Admin\Profile;
4
5
use Rudolf\Component\Auth\Auth;
6
use Rudolf\Framework\Model\AdminModel;
7
8
class AddModel extends AdminModel
9
{
10
    public function add($p)
11
    {
12
        $auth = new Auth($this->pdo, $this->prefix);
13
        $hash = $auth->getPasswordHash($p['password']);
14
15
        $stmt = $this->pdo->prepare("INSERT INTO {$this->prefix}users SET
16
            nick = :nick, first_name = :first_name, surname = :surname, email = :email,
17
            password = :password, active = :active");
18
        $stmt->bindValue(':nick', $p['nick']);
19
        $stmt->bindValue(':first_name', $p['first_name']);
20
        $stmt->bindValue(':surname', $p['surname']);
21
        $stmt->bindValue(':email', $p['email']);
22
        $stmt->bindValue(':password', $hash);
23
        $stmt->bindValue(':active', $p['active']);
24
        $stmt->execute();
25
26
        return $this->pdo->lastInsertId();
27
    }
28
}
29