blob: 3ed831dc2facbac752c3d4c1ccb7a81961c9676d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
<?php
class User
{
protected $level = 0;
public function __construct($datas = []) {
if(!empty($datas)) {
$this->hydrate($datas);
}
}
public function hydrate(array $datas = [])
{
foreach ($datas as $key => $value) {
$method = 'set' . $key;
if (method_exists($this, $method)) {
$this->$method($value);
}
}
}
public function setlevel($level)
{
$this->level = $level;
}
public function level()
{
return $this->level;
}
}
?>
|