public function quote($value, $type = null): string
    {
        if (null === $value) {
            return 'NULL';
        }

        $resource = $this->getResource(); // forces connecting if not connected yet
        if (null !== $type) {
            return "'" . pg_escape_string($resource, $this->getTypeConverter($type)->output($value)) . "'";
        } else {
            return "'" . pg_escape_string(
                $resource,
                $this->getTypeConverterFactory()
                    ->getConverterForPHPValue($value)
                    ->output($value)
            ) . "'";
        }
    }