/**
* replace user agent in text to user agent from actual environment
*
* @param string $text
*
* @return string
*/
private function replaceUserAgent(string $text): string {
$client = new Client();
$userAgent = str_replace('/', '\/', ($client->getConfig('headers')['User-Agent']));
$result = preg_replace('/"user_agent":"(Guzzle[A-Za-z0-9 . \/\\\]*)"/', '"user_agent":"' . $userAgent . '"', $text);
//or $result = preg_replace('/"user_agent":"GuzzleHttp(.*)"/', '"user_agent":"' . $userAgent . '"', $text);
//. kropka - dowolny znak * oznacza dowolną ilosc razy bez gwiazdki brało by pod uwagę tylko pierwszy znak.
return $result;
}