Lines
0.00%
0 / 3
Functions and Methods
0.00%
0 / 2
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| WireVariants | 0.00% | 0 / 3 | 0.00% | 0 / 2 | 12 | 0.00% | 0 / 1 | |||
| __construct | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| findVariantName | 0.00% | 0 / 2 | 0.00% | 0 / 1 | 6 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Contracts\Wire; | |
| 6 | ||
| 7 | use Attribute; | |
| 8 | ||
| 9 | /** @internal */ | |
| 10 | #[Attribute(Attribute::TARGET_CLASS)] | |
| 11 | final readonly class WireVariants | |
| 12 | { | |
| 13 | /** @param array<string, class-string> $variants */ | |
| 14 | public function __construct( | |
| 15 | public string $key, | |
| 16 | public array $variants, | |
| 17 | ) {} | |
| 18 | ||
| 19 | public function findVariantName(object $value): ?string | |
| 20 | { | |
| 21 | $name = array_search($value::class, $this->variants, true); | |
| 22 | ||
| 23 | return \is_string($name) ? $name : null; | |
| 24 | } | |
| 25 | } |