-
Notifications
You must be signed in to change notification settings - Fork 0
/
UserBuilder.php
40 lines (40 loc) · 1.54 KB
/
UserBuilder.php
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
38
39
40
<?php
require_once dirname(__FILE__) . '/Define.php';
require_once dirname(__FILE__) . '/Builder.php';
require_once dirname(__FILE__) . '/Parts/UserModel.php';
require_once dirname(__FILE__) . '/Parts/Age.php';
require_once dirname(__FILE__) . '/Parts/Level.php';
require_once dirname(__FILE__) . '/Parts/Location.php';
require_once dirname(__FILE__) . '/Parts/Name.php';
require_once dirname(__FILE__) . '/Parts/Todo.php';
class UserBuilder implements Builder {
private $model;
public $data;
public function __construct(){
$this->model = new UserModel;
}
public function setName(string $name) : Builder{
$this->model->set('name',UserName::main($name));
return $this;
}
public function setAge(int $age) : Builder{
$this->model->set('age',UserAge::main($age));
return $this;
}
public function setLevel(string $level) : Builder{
$this->model->set('level',UserLevel::main($level));
return $this;
}
public function setLocation(string $location) : Builder{
$this->model->set('location',UserLocation::main($location));
return $this;
}
public function setTodo(string $role = 'member') : Builder{
$this->model->set('todo',UserTodo::main($role));
return $this;
}
public function build() : array{
$this->model->data['todo'] = json_decode($this->model->data['todo'],true);
return $this->model->data;
}
}