Conditions | 2 |
Paths | 2 |
Total Lines | 10 |
Code Lines | 5 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 6 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
43 | public static function read(string $haystack, array|string $needle): ?string |
||
44 | { |
||
45 | $needle = \array_map(static fn(string $item): string => \preg_quote($item), (array) $needle); |
||
46 | $pattern = \sprintf('/\b(?:%s)=([^;]+)/i', \implode('|', $needle)); |
||
47 | |||
48 | if (\preg_match($pattern, $haystack, $matches)) { |
||
49 | return $matches[1]; |
||
50 | } |
||
51 | |||
52 | return null; |
||
53 | } |
||
55 |