> */ private array $data = []; public function has(string $a, string $b, bool $areMutuallyExclusive): bool { $first = $this->data[$a] ?? null; $result = $first !== null && isset($first[$b]) ? $first[$b] : null; if ($result === null) { return false; } // areMutuallyExclusive being false is a superset of being true, // hence if we want to know if this PairSet "has" these two with no // exclusivity, we have to ensure it was added as such. if ($areMutuallyExclusive === false) { return $result === false; } return true; } public function add(string $a, string $b, bool $areMutuallyExclusive): void { $this->pairSetAdd($a, $b, $areMutuallyExclusive); $this->pairSetAdd($b, $a, $areMutuallyExclusive); } private function pairSetAdd(string $a, string $b, bool $areMutuallyExclusive): void { $this->data[$a] ??= []; $this->data[$a][$b] = $areMutuallyExclusive; } }