1 | <?php |
||
2 | |||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
3 | namespace SchulIT\IdpExchange\Response\Builder; |
||
4 | |||
5 | use SchulIT\IdpExchange\Response\AbstractAttribute; |
||
6 | use SchulIT\IdpExchange\Response\UserResponse; |
||
7 | use SchulIT\IdpExchange\Response\ValueAttribute; |
||
8 | use SchulIT\IdpExchange\Response\ValuesAttribute; |
||
9 | |||
10 | class UserResponseBuilder { |
||
0 ignored issues
–
show
|
|||
11 | |||
12 | /** |
||
0 ignored issues
–
show
|
|||
13 | * @var string |
||
14 | */ |
||
15 | private $username; |
||
0 ignored issues
–
show
|
|||
16 | |||
17 | /** |
||
0 ignored issues
–
show
|
|||
18 | * @var AbstractAttribute |
||
19 | */ |
||
20 | private $attributes = [ ]; |
||
0 ignored issues
–
show
|
|||
21 | |||
22 | /** |
||
0 ignored issues
–
show
|
|||
23 | * @param string $username |
||
0 ignored issues
–
show
|
|||
24 | * @return UserResponseBuilder |
||
0 ignored issues
–
show
|
|||
25 | */ |
||
26 | 2 | public function setUsername(string $username): UserResponseBuilder { |
|
0 ignored issues
–
show
|
|||
27 | 2 | $this->username = $username; |
|
28 | 2 | return $this; |
|
29 | } |
||
30 | |||
31 | /** |
||
0 ignored issues
–
show
|
|||
32 | * @param string $name |
||
0 ignored issues
–
show
|
|||
33 | * @param string|null $value |
||
0 ignored issues
–
show
|
|||
34 | * @return UserResponseBuilder |
||
0 ignored issues
–
show
|
|||
35 | */ |
||
36 | 2 | public function addValueAttribute(string $name, ?string $value): UserResponseBuilder { |
|
0 ignored issues
–
show
|
|||
37 | 2 | $attribute = new ValueAttribute(); |
|
38 | 2 | $attribute->name = $name; |
|
39 | 2 | $attribute->value = $value; |
|
40 | |||
41 | 2 | $this->attributes[] = $attribute; |
|
42 | 2 | return $this; |
|
43 | } |
||
44 | |||
45 | /** |
||
0 ignored issues
–
show
|
|||
46 | * @param string $name |
||
0 ignored issues
–
show
|
|||
47 | * @param array $values |
||
0 ignored issues
–
show
|
|||
48 | * @return UserResponseBuilder |
||
0 ignored issues
–
show
|
|||
49 | */ |
||
50 | 1 | public function addValuesAttribute(string $name, array $values): UserResponseBuilder { |
|
0 ignored issues
–
show
|
|||
51 | 1 | $attribute = new ValuesAttribute(); |
|
52 | 1 | $attribute->name = $name; |
|
53 | 1 | $attribute->values = $values; |
|
54 | |||
55 | 1 | $this->attributes[] = $attribute; |
|
56 | 1 | return $this; |
|
57 | } |
||
58 | |||
59 | /** |
||
0 ignored issues
–
show
|
|||
60 | * @return UserResponse |
||
61 | */ |
||
62 | 5 | public function build(): UserResponse { |
|
0 ignored issues
–
show
|
|||
63 | 5 | $userResponse = new UserResponse(); |
|
64 | 5 | $userResponse->username = $this->username; |
|
65 | 5 | $userResponse->attributes = $this->attributes; |
|
66 | |||
67 | 5 | return $userResponse; |
|
68 | } |
||
69 | } |