| Conditions | 2 |
| Paths | 2 |
| Total Lines | 21 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 2.0185 |
| Changes | 0 | ||
| 1 | <?php |
||
| 41 | 4 | public static function fromResponse(ResponseInterface $response): self |
|
| 42 | { |
||
| 43 | 4 | $command = 'CAPABILITY '; |
|
| 44 | 4 | $commandLength = strlen($command); |
|
| 45 | |||
| 46 | 4 | $body = $response->getBody(); |
|
| 47 | 4 | if (substr($body,0, $commandLength) !== $command) { |
|
| 48 | throw new \InvalidArgumentException( |
||
| 49 | sprintf('Expected CAPABILITY command, got %s', $body) |
||
| 50 | ); |
||
| 51 | } |
||
| 52 | |||
| 53 | 4 | $advertisements = preg_split('/[\s]+/', substr($body, $commandLength)); |
|
| 54 | |||
| 55 | 4 | return new self( |
|
| 56 | 4 | array_combine( |
|
| 57 | 4 | $advertisements, |
|
| 58 | 4 | array_fill(0, count($advertisements), true) |
|
| 59 | ) |
||
| 60 | ); |
||
| 61 | } |
||
| 62 | |||
| 63 | } |