Passed
Push — master ( 7f7d2c...7dbe13 )
by Daimona
02:03
created

RegexUtils   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A regexFromArray() 0 6 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( string $delimiter = '/', IRegexAble ...$elements ) : string {
14
		$bits = [];
15
		foreach ( $elements as $el ) {
16
			$bits[] = $el->getRegex( $delimiter );
17
		}
18
		return '(?:' . implode( '|', $bits ) . ')';
19
	}
20
}
21