Skip to content

Commit 74c24e6

Browse files
committed
DI of Client in Trello
1 parent cbe39f9 commit 74c24e6

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

examples/all_boards.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77

88
require ".config";
99

10-
$trello = new Trello($key, $token);
10+
$client = new Trello\Client();
11+
$client->authenticate($key, $token, Client::AUTH_URL_CLIENT_ID);
12+
13+
$trello = new Trello($client);
1114
$models = $trello->getTeams();
1215

1316
print_r($models);

lib/Trello.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ class Trello
1414
{
1515
private $client;
1616

17-
public function __construct($key, $token)
17+
public function __construct(Client $client)
1818
{
19-
$client = new Client();
20-
$client->authenticate($key, $token, Client::AUTH_URL_CLIENT_ID);
2119
$this->client = $client;
2220
}
2321

tests/TrelloTest.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
require "vendor/autoload.php";
33

44
use \Webhooks\Wrapper\Trello;
5+
use \Webhooks\Wrapper\Trello\Client;
56

67
class TrelloTest extends \PHPUnit\Framework\TestCase
78
{
@@ -13,14 +14,18 @@ public function init($msg = "")
1314
{
1415
if (null == $this->trello) {
1516
require ".config";
16-
$this->trello = new \Webhooks\Wrapper\Trello($key, $token);
17+
$client = new Client();
18+
$client->authenticate($key, $token, Client::AUTH_URL_CLIENT_ID);
19+
$this->trello = new \Webhooks\Wrapper\Trello($client);
1720
}
1821
}
1922

2023
public function testInit()
2124
{
2225
require ".config";
23-
$trello = new \Webhooks\Wrapper\Trello($key, $token);
26+
$client = new Client();
27+
$client->authenticate($key, $token, Client::AUTH_URL_CLIENT_ID);
28+
$trello = new \Webhooks\Wrapper\Trello($client);
2429
$this->assertTrue(true);
2530
return $trello;
2631
}

0 commit comments

Comments
 (0)