Last active
December 24, 2023 21:44
-
-
Save mcsee/0dae05cfead4089b3da9c93669e193f1 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 removeDuplicates( | |
array $patternsWithPossibleDuplicates): array { | |
return array_intersect_key( | |
$patternsWithPossibleDuplicates, | |
array_unique( | |
array_map("strtolower", $patternsWithPossibleDuplicates))); | |
} | |
function simplify(array $patterns): array { | |
$patternsWithoutDuplicates = $this->removeDuplicates($patterns); | |
return array_values(array_filter($patternsWithoutDuplicates, | |
fn ($outerPattern) => | |
$this->alreadyIncludesPattern( | |
$patternsWithoutDuplicates, $outerPattern))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment