Last active
August 23, 2023 00:28
-
-
Save mcsee/c1a978fb7b7ca24fed559ab83844887c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
private function alreadyIncludesPattern( | |
array $patternsWithoutDuplicates, string $needlePattern): bool { | |
foreach ($patternsWithoutDuplicates as $innerPattern) { | |
if ($needlePattern != $innerPattern && | |
(stripos($needlePattern, $innerPattern) !== false)) { | |
return false; | |
} | |
} | |
return true; | |
} | |
function simplify(array $patterns): array { | |
return array_values(array_filter($patterns, | |
fn ($outerPattern) => | |
$this->alreadyIncludesPattern($patterns, $outerPattern))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment