hashType = $hashType; $this->value = $value; } function getExpression(SQL $sql, array &$params): string { if ($sql instanceof MySQL) { $val = $sql->addValue($this->value, $params); return match ($this->hashType) { self::SHA_128 => "SHA2($val, 128)", self::SHA_256 => "SHA2($val, 256)", self::SHA_512 => "SHA2($val, 512)", default => throw new \Exception("HASH() not implemented for hash type: " . $this->hashType), }; } elseif ($sql instanceof PostgreSQL) { $val = $sql->addValue($this->value, $params); return match ($this->hashType) { self::SHA_128 => "digest($val, 'sha128')", self::SHA_256 => "digest($val, 'sha256')", self::SHA_512 => "digest($val, 'sha512')", default => throw new \Exception("HASH() not implemented for hash type: " . $this->hashType), }; } else { throw new \Exception("HASH() not implemented for driver type: " . get_class($sql)); } } }