I have a class that takes in lines of text and uses about 15 different "criteria" (individual preg_match statements) to check if the line should qualify to be saved in an array.
How does one best handle such a situation with clean, maintainable code?
Initially I had a crazy long if statement which had all the criteria, for example:
if (
preg_match($criteria1,$line) &&
preg_match($criteria2, $line) &&
...
...
...
preg_match($criteriaN,$line)
) {
//do something, e.g. save the line to an array.
}
I've since put each preg_match statement into a different function within a separate class and call each function in a row, checking if it's true... But now I have 15 separate functions that are only subtly different from each other and it still doesn't feel like I'm writing good code. How is it best to handle this situation?