Skip to content

Commit 393ba18

Browse files
committed
bug fix & packge replace
1 parent dcf0f41 commit 393ba18

File tree

4 files changed

+11
-13
lines changed

4 files changed

+11
-13
lines changed

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lanlin/nylas-php",
3-
"description": "Nylas PHP SDK (api version 2.2)",
3+
"description": "Nylas PHP SDK (api version 2.3)",
44
"license": "MIT",
55
"authors" : [
66
{
@@ -16,9 +16,9 @@
1616
"zbateson/mail-mime-parser": "^2.0"
1717
},
1818
"require-dev": {
19+
"fakerphp/faker": "^1.19",
1920
"phpunit/phpunit": "^9.5",
2021
"mockery/mockery": "^1.4",
21-
"fzaninotto/faker": "dev-master",
2222
"nunomaduro/collision": "^6.1",
2323
"roave/security-advisories": "dev-latest"
2424
},

src/Client.php

+7-9
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* Nylas Client
1111
* ----------------------------------------------------------------------------------
1212
*
13+
* @property Utilities\Options Options
1314
* @property Authentication\Abs Authentication
1415
* @property Calendars\Abs Calendars
1516
* @property Contacts\Abs Contacts
@@ -29,17 +30,12 @@
2930
* @property Webhooks\Abs Webhooks
3031
*
3132
* @author lanlin
32-
* @change 2022/01/27
33+
* @change 2022/03/09
3334
*/
3435
class Client
3536
{
3637
// ------------------------------------------------------------------------------
3738

38-
/**
39-
* @var Options
40-
*/
41-
public Options $options;
42-
4339
/**
4440
* @var array
4541
*/
@@ -62,7 +58,7 @@ class Client
6258
*/
6359
public function __construct(array $options)
6460
{
65-
$this->options = new Options($options);
61+
$this->objects['Options'] = new Options($options);
6662
}
6763

6864
// ------------------------------------------------------------------------------
@@ -90,20 +86,22 @@ public function __get(string $name): object
9086
*/
9187
private function callSubClass(string $name): object
9288
{
89+
$name = \ucfirst($name);
90+
9391
if (!empty($this->objects[$name]))
9492
{
9593
return $this->objects[$name];
9694
}
9795

98-
$apiClass = __NAMESPACE__.'\\'.\ucfirst($name).'\\Abs';
96+
$apiClass = __NAMESPACE__.'\\'.$name.'\\Abs';
9997

10098
// check class exists
10199
if (!\class_exists($apiClass))
102100
{
103101
throw new NylasException(null, "class {$apiClass} not found!");
104102
}
105103

106-
return $this->objects[$name] = new $apiClass($this->options);
104+
return $this->objects[$name] = new $apiClass($this->objects['Options']);
107105
}
108106

109107
// ------------------------------------------------------------------------------

src/Utilities/Options.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function setHandler(?callable $handler): void
100100
/**
101101
* get access token
102102
*
103-
* @return string
103+
* @return null|callable
104104
*/
105105
public function getHandler(): ?callable
106106
{

tests/AbsCase.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ protected function mockResponse(array $data, array $header = [], int $code = 200
186186

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

189-
$this->client->options->setHandler($mock);
189+
$this->client->Options->setHandler($mock);
190190
}
191191

192192
// ------------------------------------------------------------------------------

0 commit comments

Comments
 (0)