ba = $ba; $this->hashers = $hashers; } /** * @param string $item * @return void */ public function add($item) { $vals = $this->hashers->hash($item); foreach ($vals as $bitLoc) { $this->ba[$bitLoc] = true; } } /** * @param string $item * @return bool */ public function exists($item) { $exists = true; $vals = $this->hashers->hash($item); foreach ($vals as $bitLoc) { if (!$this->ba[$bitLoc]) { $exists = false; break; } } return $exists; } /** * @return array */ public function jsonSerialize() { return [ 'bit_array' => $this->ba, 'hashers' => $this->hashers, ]; } }