diff --git a/src/Helper/MyParcelCurl.php b/src/Helper/MyParcelCurl.php index 9dc809f5..6fe606c8 100644 --- a/src/Helper/MyParcelCurl.php +++ b/src/Helper/MyParcelCurl.php @@ -272,7 +272,7 @@ public function getInfo($opt = 0) */ public function setUserAgent($agent) { - return curl_setopt($this->_getResource(), CURLOPT_USERAGENT, $agent); + return curl_setopt($this->_getResource(), CURLOPT_USERAGENT, (string)$agent); } /** diff --git a/src/Model/MyParcelRequest.php b/src/Model/MyParcelRequest.php index de5195d5..658b3554 100644 --- a/src/Model/MyParcelRequest.php +++ b/src/Model/MyParcelRequest.php @@ -257,11 +257,14 @@ public function setUserAgent($userAgent) */ public function getUserAgentFromComposer() { - $composerData = file_get_contents('../../composer.json'); - $jsonComposerData = json_decode($composerData, true); - if (!empty($jsonComposerData['version'])) { - $version = str_replace('v', '', $jsonComposerData['version']); - return 'MyParcelNL-SDK/' . $version; + $composer = 'vendor/myparcelnl/sdk/composer.json'; + if (file_exists($composer)) { + $composerData = file_get_contents($composer); + $jsonComposerData = json_decode($composerData, true); + if (!empty($jsonComposerData['version'])) { + $version = str_replace('v', '', $jsonComposerData['version']); + return 'MyParcelNL-SDK/' . $version; + } } return null;