| Total Complexity | 6 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 12 | final class EnableByMatchingSegment implements ToggleStrategy |
||
| 13 | { |
||
| 14 | public const NAME = 'enable_by_matching_segment'; |
||
| 15 | private Segments $segments; |
||
| 16 | |||
| 17 | 8 | public function __construct(Segments $segments) |
|
| 18 | { |
||
| 19 | 8 | $this->segments = $segments; |
|
| 20 | 8 | } |
|
| 21 | |||
| 22 | 6 | public function isSatisfiedBy(ConsumerIdentity $identity): bool |
|
| 23 | { |
||
| 24 | 6 | foreach ($this->segments->all() as $segment) { |
|
| 25 | 5 | if ($segment->match($identity->payload())) { |
|
| 26 | 3 | return true; |
|
| 27 | } |
||
| 28 | } |
||
| 29 | |||
| 30 | 3 | return false; |
|
| 31 | } |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @return array<string, string|array> |
||
| 35 | */ |
||
| 36 | 1 | public function toArray(): array |
|
| 43 | ), |
||
| 44 | ]; |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @return array<string, string|array> |
||
| 49 | */ |
||
| 50 | 1 | public function jsonSerialize(): array |
|
| 53 | } |
||
| 54 | } |
||
| 55 |