| Total Complexity | 7 |
| Total Lines | 61 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 19 | final class Pair implements Argument |
||
| 20 | { |
||
| 21 | private $key; |
||
| 22 | private $value; |
||
| 23 | |||
| 24 | 6 | private function __construct(Argument $key, Argument $value) |
|
| 25 | { |
||
| 26 | 6 | if ($key instanceof Unwind || $value instanceof Unwind) { |
|
| 27 | 2 | throw new LogicException; |
|
| 28 | } |
||
| 29 | |||
| 30 | 4 | $this->key = $key; |
|
| 31 | 4 | $this->value = $value; |
|
| 32 | 4 | } |
|
| 33 | |||
| 34 | /** |
||
| 35 | * {@inheritdoc} |
||
| 36 | */ |
||
| 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 | ); |
||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * {@inheritdoc} |
||
| 59 | */ |
||
| 60 | 2 | public function resolve( |
|
| 80 | } |
||
| 81 | } |
||
| 82 |