RegexUtils   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 17
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A regexFromArray() 0 9 2
1
<?php declare( strict_types=1 );
2
3
namespace BotRiconferme\Utils;
4
5
class RegexUtils {
6
	/**
7
	 * Get a regex matching any element in the given array
8
	 *
9
	 * @param string $delimiter
10
	 * @param IRegexable ...$elements
11
	 * @return string
12
	 */
13
	public static function regexFromArray(
14
		string $delimiter = '/',
15
		IRegexable ...$elements
16
	): string {
17
		$bits = [];
18
		foreach ( $elements as $el ) {
19
			$bits[] = $el->getRegex( $delimiter );
20
		}
21
		return '(?:' . implode( '|', $bits ) . ')';
22
	}
23
}
24