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