Skip to content

Commit

Permalink
Load the composer file directly from the package dir
Browse files Browse the repository at this point in the history
  • Loading branch information
betacar committed Nov 4, 2020
1 parent 51602e7 commit 6d967db
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/Bynder/Api/Impl/OAuth2/Configuration.php
Expand Up @@ -17,7 +17,7 @@
class Configuration
{
private $bynderDomain;

private $rootDir;
private $redirectUri;

/**
Expand Down Expand Up @@ -52,7 +52,8 @@ public function __construct($bynderDomain, $redirectUri, $clientId, $clientSecre
$this->clientSecret = $clientSecret;
$this->token = $token;
$this->requestOptions = $requestOptions;
$this->package = json_decode(file_get_contents('composer.json'));
$this->rootDir = dirname(__FILE__, 6);
$this->package = json_decode(file_get_contents($this->rootDir . '/composer.json'));
$this->initialToken = $token;
}

Expand Down Expand Up @@ -145,6 +146,6 @@ public function setRequestOptions(array $requestOptions)
*/
public function getSdkVersion()
{
return $this->package['version'];
return $this->package->version;
}
}
6 changes: 4 additions & 2 deletions src/Bynder/Api/Impl/PermanentTokens/Configuration.php
Expand Up @@ -12,6 +12,7 @@
class Configuration
{
private $bynderDomain;
private $rootDir;

/**
* @var string Permanent token.
Expand All @@ -30,7 +31,8 @@ public function __construct($bynderDomain, $token, $requestOptions = [])
$this->bynderDomain = $bynderDomain;
$this->token = $token;
$this->requestOptions = $requestOptions;
$this->package = json_decode(file_get_contents('composer.json'));
$this->rootDir = dirname(__FILE__, 6);
$this->package = json_decode(file_get_contents($this->rootDir . '/composer.json'));
}

public function getBynderDomain()
Expand Down Expand Up @@ -80,6 +82,6 @@ public function setRequestOptions(array $requestOptions)
*/
public function getSdkVersion()
{
return $this->package['version'];
return $this->package->version;
}
}

0 comments on commit 6d967db

Please sign in to comment.