Skip to content

Commit

Permalink
bug fix & packge replace
Browse files Browse the repository at this point in the history
  • Loading branch information
lanlin committed Mar 9, 2022
1 parent dcf0f41 commit 393ba18
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lanlin/nylas-php",
"description": "Nylas PHP SDK (api version 2.2)",
"description": "Nylas PHP SDK (api version 2.3)",
"license": "MIT",
"authors" : [
{
Expand All @@ -16,9 +16,9 @@
"zbateson/mail-mime-parser": "^2.0"
},
"require-dev": {
"fakerphp/faker": "^1.19",
"phpunit/phpunit": "^9.5",
"mockery/mockery": "^1.4",
"fzaninotto/faker": "dev-master",
"nunomaduro/collision": "^6.1",
"roave/security-advisories": "dev-latest"
},
Expand Down
16 changes: 7 additions & 9 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* Nylas Client
* ----------------------------------------------------------------------------------
*
* @property Utilities\Options Options
* @property Authentication\Abs Authentication
* @property Calendars\Abs Calendars
* @property Contacts\Abs Contacts
Expand All @@ -29,17 +30,12 @@
* @property Webhooks\Abs Webhooks
*
* @author lanlin
* @change 2022/01/27
* @change 2022/03/09
*/
class Client
{
// ------------------------------------------------------------------------------

/**
* @var Options
*/
public Options $options;

/**
* @var array
*/
Expand All @@ -62,7 +58,7 @@ class Client
*/
public function __construct(array $options)
{
$this->options = new Options($options);
$this->objects['Options'] = new Options($options);
}

// ------------------------------------------------------------------------------
Expand Down Expand Up @@ -90,20 +86,22 @@ public function __get(string $name): object
*/
private function callSubClass(string $name): object
{
$name = \ucfirst($name);

if (!empty($this->objects[$name]))
{
return $this->objects[$name];
}

$apiClass = __NAMESPACE__.'\\'.\ucfirst($name).'\\Abs';
$apiClass = __NAMESPACE__.'\\'.$name.'\\Abs';

// check class exists
if (!\class_exists($apiClass))
{
throw new NylasException(null, "class {$apiClass} not found!");
}

return $this->objects[$name] = new $apiClass($this->options);
return $this->objects[$name] = new $apiClass($this->objects['Options']);
}

// ------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/Utilities/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function setHandler(?callable $handler): void
/**
* get access token
*
* @return string
* @return null|callable
*/
public function getHandler(): ?callable
{
Expand Down
2 changes: 1 addition & 1 deletion tests/AbsCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ protected function mockResponse(array $data, array $header = [], int $code = 200

$mock = new MockHandler([new Response($code, $header, $body)]);

$this->client->options->setHandler($mock);
$this->client->Options->setHandler($mock);
}

// ------------------------------------------------------------------------------
Expand Down

0 comments on commit 393ba18

Please sign in to comment.