endpoint = $endpoint; $this->httpClient = $httpClient; } /** * @param string $endpoint * @param http_client_interface $httpClient * @return client */ public static function getInstance(string $endpoint, http_client_interface $httpClient): client { if (self::$instance === null) { self::$instance = new client($endpoint, $httpClient); } return self::$instance; } /** * @param array $data * @return bool|string * @throws Exception */ public function send_data(array $data): bool|string { try { return $this->httpClient->post($this->endpoint, $data); } catch (Exception $e) { throw new Exception('HTTP request error: ' . $e->getMessage()); } } }