Lines
100.00%
6 / 6
Methods
100.00%
3 / 3
Classes
100.00%
1 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| withArgument | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| toBoundArguments | 100.00% | 4 / 4 | 100.00% | 1 / 1 | 1 | ||
| 9 | final readonly class NamedArguments | |
| 10 | { | |
| 11 | /** @param array<string, mixed> $values */ | |
| 12 | public function __construct(private array $values = []) {} | |
| 13 | ||
| 14 | public function withArgument(string $name, mixed $value): self | |
| 15 | { | |
| 16 | return new self([...$this->values, '$' . $name => $value]); | |
| 17 | } | |
| 18 | ||
| 19 | // Tracked, so compiling fails when no service takes a bound name, e.g. after a parameter rename. | |
| 20 | /** @return array<string, BoundArgument> */ | |
| 21 | public function toBoundArguments(): array | |
| 22 | { | |
| 23 | return array_map( | |
| 24 | static fn(mixed $value): BoundArgument => new BoundArgument($value, true), | |
| 25 | $this->values, | |
| 26 | ); | |
| 27 | } | |
| 28 | } |