| Conditions | 2 |
| Paths | 2 |
| Total Lines | 20 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 50 | 7 | public static function fromString(string $response): self |
|
| 51 | { |
||
| 52 | 7 | $command = 'CAPABILITY '; |
|
| 53 | 7 | $commandLength = strlen($command); |
|
| 54 | |||
| 55 | 7 | if (substr($response,0, $commandLength) !== $command) { |
|
| 56 | 1 | throw new \InvalidArgumentException( |
|
| 57 | 1 | sprintf('Expected CAPABILITY command, got %s', $response) |
|
| 58 | ); |
||
| 59 | } |
||
| 60 | |||
| 61 | 6 | $advertisements = preg_split('/[\s]+/', substr($response, $commandLength)); |
|
| 62 | |||
| 63 | 6 | return new self( |
|
| 64 | 6 | array_combine( |
|
| 65 | 6 | $advertisements, |
|
| 66 | 6 | array_fill(0, count($advertisements), true) |
|
| 67 | ) |
||
| 68 | ); |
||
| 69 | } |
||
| 70 | |||
| 71 | } |