Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
14 / 14 |
|
100.00% |
11 / 11 |
CRAP | |
100.00% |
1 / 1 |
User | |
100.00% |
14 / 14 |
|
100.00% |
11 / 11 |
11 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getEmail | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getUserType | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setEmail | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setPassword | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setUserType | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setId | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
exists | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | namespace Models; |
3 | |
4 | class User { |
5 | private $id; |
6 | private $name; |
7 | private $email; |
8 | private $password; |
9 | private $userType; |
10 | |
11 | public function __construct() { |
12 | $this->userType = 'user'; |
13 | } |
14 | |
15 | // Getters |
16 | public function getId() { return $this->id; } |
17 | public function getName() { return $this->name; } |
18 | public function getEmail() { return $this->email; } |
19 | public function getUserType() { return $this->userType; } |
20 | |
21 | // Setters |
22 | public function setName($name) { $this->name = $name; } |
23 | public function setEmail($email) { $this->email = $email; } |
24 | public function setPassword($password) { |
25 | $this->password = password_hash($password, PASSWORD_DEFAULT); |
26 | } |
27 | public function setUserType($userType) { $this->userType = $userType; } |
28 | public function setId($id) { |
29 | $this->id = $id; |
30 | return $this; |
31 | } |
32 | |
33 | public function exists($conn) { |
34 | $stmt = $conn->prepare("SELECT id FROM users WHERE id = ?"); |
35 | $stmt->execute([$this->id]); |
36 | return $stmt->rowCount() > 0; |
37 | } |
38 | } |