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