Skip to content

Commit

Permalink
if composer file == find
Browse files Browse the repository at this point in the history
  • Loading branch information
Reindert committed Jul 6, 2017
1 parent 6ebc0d1 commit ede441e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Helper/MyParcelCurl.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
13 changes: 8 additions & 5 deletions src/Model/MyParcelRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ede441e

Please sign in to comment.