| Conditions | 4 |
| Paths | 3 |
| Total Lines | 17 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 6 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 21 | public function profile(string $userId, array $fields = []): UserResponse |
||
| 22 | { |
||
| 23 | 3 | $allowedFields = $this->getAllowedFields(); |
|
| 24 | if (!empty($fields)) { |
||
| 25 | 3 | foreach ($fields as $field) { |
|
| 26 | 3 | if (!\in_array($field, $allowedFields, true)) { |
|
| 27 | throw new \InvalidArgumentException($field . ' is not a valid value. $fields must only contain ' . implode(', ', $allowedFields)); |
||
| 28 | } |
||
| 29 | } |
||
| 30 | } else { |
||
| 31 | $fields = $allowedFields; |
||
| 32 | } |
||
| 33 | |||
| 34 | 1 | $request = new UserRequest($this->pageToken, $fields); |
|
| 35 | $response = $this->client->get($userId, $request->build()); |
||
| 36 | 1 | ||
| 37 | 1 | return new UserResponse($response); |
|
| 38 | } |
||
| 56 |