Skip to content

Instantly share code, notes, and snippets.

@mcsee
Last active December 24, 2023 21:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcsee/0dae05cfead4089b3da9c93669e193f1 to your computer and use it in GitHub Desktop.
Save mcsee/0dae05cfead4089b3da9c93669e193f1 to your computer and use it in GitHub Desktop.
<?
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