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