| Total Complexity | 8 |
| Total Lines | 68 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 21 | final class Pair implements Argument |
||
| 22 | { |
||
| 23 | private $key; |
||
| 24 | private $value; |
||
| 25 | |||
| 26 | 10 | private function __construct(Argument $key, Argument $value) |
|
| 27 | { |
||
| 28 | 10 | if ($key instanceof Unwind || $value instanceof Unwind) { |
|
| 29 | 2 | throw new LogicException; |
|
| 30 | } |
||
| 31 | |||
| 32 | 8 | $this->key = $key; |
|
| 33 | 8 | $this->value = $value; |
|
| 34 | 8 | } |
|
| 35 | |||
| 36 | /** |
||
| 37 | * {@inheritdoc} |
||
| 38 | */ |
||
| 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 | ); |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * {@inheritdoc} |
||
| 61 | */ |
||
| 62 | 2 | public function resolve( |
|
| 82 | } |
||
| 83 | |||
| 84 | 3 | public function compile(): CompiledArgument |
|
| 89 | ); |
||
| 90 | } |
||
| 91 | } |
||
| 92 |