| Conditions | 3 |
| Paths | 3 |
| Total Lines | 17 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 3 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 37 | 11 | public static function fromValue($value, Arguments $arguments): Argument |
|
| 38 | { |
||
| 39 | 11 | if (!is_string($value)) { |
|
| 40 | 5 | throw new ValueNotSupported; |
|
| 41 | } |
||
| 42 | |||
| 43 | 8 | $value = Str::of($value); |
|
| 44 | |||
| 45 | 8 | if (!$value->matches('~^<\S+, ?\S+>$~')) { |
|
| 46 | 7 | throw new ValueNotSupported((string) $value); |
|
| 47 | } |
||
| 48 | |||
| 49 | 6 | $components = $value->capture('~^<(?<key>\S+), ?(?<value>\S+)>$~'); |
|
| 50 | |||
| 51 | 6 | return new self( |
|
| 52 | 6 | $arguments->load((string) $components->get('key')), |
|
| 53 | 6 | $arguments->load((string) $components->get('value')) |
|
| 54 | ); |
||
| 82 |