SchulIT /
idp-exchange-models
| 1 | <?php |
||
| 2 | |||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
| 3 | namespace SchulIT\IdpExchange\Request\Builder; |
||
| 4 | |||
| 5 | use SchulIT\IdpExchange\Request\UpdatedUsersRequest; |
||
| 6 | |||
| 7 | class UpdatedUsersRequestBuilder { |
||
|
0 ignored issues
–
show
|
|||
| 8 | /** |
||
|
0 ignored issues
–
show
|
|||
| 9 | * @var string[] |
||
| 10 | */ |
||
| 11 | private $usernames = [ ]; |
||
|
0 ignored issues
–
show
|
|||
| 12 | |||
| 13 | /** |
||
|
0 ignored issues
–
show
|
|||
| 14 | * @var \DateTime |
||
| 15 | */ |
||
| 16 | private $since = null; |
||
|
0 ignored issues
–
show
|
|||
| 17 | |||
| 18 | /** |
||
|
0 ignored issues
–
show
|
|||
| 19 | * @param string $username |
||
|
0 ignored issues
–
show
|
|||
| 20 | * @return $this |
||
|
0 ignored issues
–
show
|
|||
| 21 | */ |
||
| 22 | 1 | public function addUser(string $username): UpdatedUsersRequestBuilder { |
|
|
0 ignored issues
–
show
|
|||
| 23 | 1 | $this->usernames[] = $username; |
|
| 24 | 1 | return $this; |
|
| 25 | } |
||
| 26 | |||
| 27 | /** |
||
|
0 ignored issues
–
show
|
|||
| 28 | * @param string[] $users |
||
|
0 ignored issues
–
show
|
|||
| 29 | * @return UpdatedUsersRequestBuilder |
||
|
0 ignored issues
–
show
|
|||
| 30 | */ |
||
| 31 | 2 | public function addUsers(array $users): UpdatedUsersRequestBuilder { |
|
|
0 ignored issues
–
show
|
|||
| 32 | 2 | $this->usernames = array_merge($this->usernames, $users); |
|
| 33 | 2 | return $this; |
|
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
|
0 ignored issues
–
show
|
|||
| 37 | * @param \DateTime $dateTime |
||
|
0 ignored issues
–
show
|
|||
| 38 | * @return UpdatedUsersRequestBuilder |
||
|
0 ignored issues
–
show
|
|||
| 39 | */ |
||
| 40 | public function since(\DateTime $dateTime): UpdatedUsersRequestBuilder { |
||
|
0 ignored issues
–
show
|
|||
| 41 | $this->since = $dateTime; |
||
| 42 | return $this; |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
|
0 ignored issues
–
show
|
|||
| 46 | * @return UpdatedUsersRequest |
||
| 47 | */ |
||
| 48 | 3 | public function build(): UpdatedUsersRequest { |
|
|
0 ignored issues
–
show
|
|||
| 49 | 3 | $request = new UpdatedUsersRequest(); |
|
| 50 | 3 | $request->usernames = $this->usernames; |
|
| 51 | 3 | if($this->since !== null) { |
|
|
0 ignored issues
–
show
|
|||
| 52 | $request->since = clone $this->since; |
||
| 53 | } |
||
| 54 | |||
| 55 | 3 | return $request; |
|
| 56 | } |
||
| 57 | } |