SchulIT /
idp-exchange-models
| 1 | <?php |
||
| 2 | |||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
| 3 | namespace SchulIT\IdpExchange\Response\Builder; |
||
| 4 | |||
| 5 | use SchulIT\IdpExchange\Response\UserResponse; |
||
| 6 | use SchulIT\IdpExchange\Response\UsersResponse; |
||
| 7 | |||
| 8 | class UsersResponseBuilder { |
||
|
0 ignored issues
–
show
|
|||
| 9 | |||
| 10 | /** |
||
|
0 ignored issues
–
show
|
|||
| 11 | * @var UserResponse[] |
||
| 12 | */ |
||
| 13 | private $users = [ ]; |
||
|
0 ignored issues
–
show
|
|||
| 14 | |||
| 15 | /** |
||
|
0 ignored issues
–
show
|
|||
| 16 | * @param UserResponse $userResponse |
||
|
0 ignored issues
–
show
|
|||
| 17 | * @return UsersResponseBuilder |
||
|
0 ignored issues
–
show
|
|||
| 18 | */ |
||
| 19 | 1 | public function addUser(UserResponse $userResponse): UsersResponseBuilder { |
|
|
0 ignored issues
–
show
|
|||
| 20 | 1 | $this->users[] = $userResponse; |
|
| 21 | 1 | return $this; |
|
| 22 | } |
||
| 23 | |||
| 24 | /** |
||
|
0 ignored issues
–
show
|
|||
| 25 | * @return UsersResponse |
||
| 26 | */ |
||
| 27 | 1 | public function build(): UsersResponse { |
|
|
0 ignored issues
–
show
|
|||
| 28 | 1 | $response = new UsersResponse(); |
|
| 29 | |||
| 30 | 1 | foreach($this->users as $userResponse) { |
|
|
0 ignored issues
–
show
|
|||
| 31 | 1 | $response->users[] = clone $userResponse; |
|
| 32 | } |
||
| 33 | |||
| 34 | 1 | return $response; |
|
| 35 | } |
||
| 36 | } |