*/ private $regexes = array(); public function __construct( string $patterns ) { foreach ( preg_split( '/\R/', $patterns ) as $line ) { $line = trim( $line ); if ( '' === $line || '#' === $line[0] ) { continue; } $quoted = preg_quote( Path::lower( $line ), '#' ); $this->regexes[] = '#^' . str_replace( '\*', '.*', $quoted ) . '$#u'; } } public function matches( string $path ): bool { list( $path ) = Path::split( $path ); $path = Path::lower( $path ); foreach ( $this->regexes as $regex ) { if ( 1 === preg_match( $regex, $path ) ) { return true; } } return false; } }