Skip to content

Commit 49efcab

Browse files
committed
fixes
1 parent d4ec707 commit 49efcab

File tree

3 files changed

+29
-28
lines changed

3 files changed

+29
-28
lines changed

src/Client.php

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace PulkitJalan\Google;
44

55
use Google_Client;
6+
use Illuminate\Support\Arr;
67
use PulkitJalan\Google\Exceptions\UnknownServiceException;
78

89
class Client
@@ -26,24 +27,24 @@ public function __construct(array $config, $userEmail = '')
2627
$this->config = $config;
2728

2829
// create an instance of the google client for OAuth2
29-
$this->client = new Google_Client(array_get($config, 'config', []));
30+
$this->client = new Google_Client(Arr::get($config, 'config', []));
3031

3132
// set application name
32-
$this->client->setApplicationName(array_get($config, 'application_name', ''));
33+
$this->client->setApplicationName(Arr::get($config, 'application_name', ''));
3334

3435
// set oauth2 configs
35-
$this->client->setClientId(array_get($config, 'client_id', ''));
36-
$this->client->setClientSecret(array_get($config, 'client_secret', ''));
37-
$this->client->setRedirectUri(array_get($config, 'redirect_uri', ''));
38-
$this->client->setScopes(array_get($config, 'scopes', []));
39-
$this->client->setAccessType(array_get($config, 'access_type', 'online'));
40-
$this->client->setApprovalPrompt(array_get($config, 'approval_prompt', 'auto'));
36+
$this->client->setClientId(Arr::get($config, 'client_id', ''));
37+
$this->client->setClientSecret(Arr::get($config, 'client_secret', ''));
38+
$this->client->setRedirectUri(Arr::get($config, 'redirect_uri', ''));
39+
$this->client->setScopes(Arr::get($config, 'scopes', []));
40+
$this->client->setAccessType(Arr::get($config, 'access_type', 'online'));
41+
$this->client->setApprovalPrompt(Arr::get($config, 'approval_prompt', 'auto'));
4142

4243
// set developer key
43-
$this->client->setDeveloperKey(array_get($config, 'developer_key', ''));
44+
$this->client->setDeveloperKey(Arr::get($config, 'developer_key', ''));
4445

4546
// auth for service account
46-
if (array_get($config, 'service.enable', false)) {
47+
if (Arr::get($config, 'service.enable', false)) {
4748
$this->auth($userEmail);
4849
}
4950
}
@@ -57,7 +58,7 @@ public function getClient()
5758
{
5859
return $this->client;
5960
}
60-
61+
6162
/**
6263
* Setter for the google client.
6364
*
@@ -68,7 +69,7 @@ public function getClient()
6869
public function setClient(Google_Client $client)
6970
{
7071
$this->client = $client;
71-
72+
7273
return $this;
7374
}
7475

@@ -118,14 +119,14 @@ protected function auth($userEmail = '')
118119
*/
119120
protected function useAssertCredentials($userEmail = '')
120121
{
121-
$serviceJsonUrl = array_get($this->config, 'service.file', '');
122+
$serviceJsonUrl = Arr::get($this->config, 'service.file', '');
122123

123124
if (empty($serviceJsonUrl)) {
124125
return false;
125126
}
126127

127128
$this->client->setAuthConfig($serviceJsonUrl);
128-
129+
129130
if (! empty($userEmail)) {
130131
$this->client->setSubject($userEmail);
131132
}

src/config/config.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
| https://developers.google.com/console
1818
|
1919
*/
20-
'client_id' => env('GOOGLE_CLIENT_ID', ''),
21-
'client_secret' => env('GOOGLE_CLIENT_SECRET', ''),
22-
'redirect_uri' => env('GOOGLE_REDIRECT', ''),
23-
'scopes' => [],
24-
'access_type' => 'online',
20+
'client_id' => env('GOOGLE_CLIENT_ID', ''),
21+
'client_secret' => env('GOOGLE_CLIENT_SECRET', ''),
22+
'redirect_uri' => env('GOOGLE_REDIRECT', ''),
23+
'scopes' => [],
24+
'access_type' => 'online',
2525
'approval_prompt' => 'auto',
2626

2727
/*
@@ -53,7 +53,7 @@
5353
/*
5454
| Path to service account json file
5555
*/
56-
'file' => env('GOOGLE_SERVICE_ACCOUNT_JSON_LOCATION', '')
56+
'file' => env('GOOGLE_SERVICE_ACCOUNT_JSON_LOCATION', ''),
5757
],
5858

5959
/*
@@ -62,9 +62,9 @@
6262
|----------------------------------------------------------------------------
6363
|
6464
| Set any additional config variables supported by the Google Client
65-
| Details can be found here:
65+
| Details can be found here:
6666
| https://github.com/google/google-api-php-client/blob/master/src/Google/Client.php
67-
|
67+
|
6868
| NOTE: If client id is specified here, it will get over written by the one above.
6969
|
7070
*/

tests/ClientTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
namespace PulkitJalan\Google\tests;
44

55
use Mockery;
6-
use PHPUnit_Framework_TestCase;
6+
use PHPUnit\Framework\TestCase;
77

8-
class ClientTest extends PHPUnit_Framework_TestCase
8+
class ClientTest extends TestCase
99
{
10-
public function tearDown()
10+
public function tearDown(): void
1111
{
1212
Mockery::close();
1313
}
@@ -41,7 +41,7 @@ public function testServiceMakeException()
4141
{
4242
$client = Mockery::mock('PulkitJalan\Google\Client', [[]])->makePartial();
4343

44-
$this->setExpectedException('PulkitJalan\Google\Exceptions\UnknownServiceException');
44+
$this->expectException('PulkitJalan\Google\Exceptions\UnknownServiceException');
4545

4646
$client->make('storag');
4747
}
@@ -50,7 +50,7 @@ public function testMagicMethodException()
5050
{
5151
$client = new \PulkitJalan\Google\Client([]);
5252

53-
$this->setExpectedException('BadMethodCallException');
53+
$this->expectException('BadMethodCallException');
5454

5555
$client->getAuthTest();
5656
}
@@ -67,7 +67,7 @@ public function testDefaultCredentials()
6767
$client = new \PulkitJalan\Google\Client([
6868
'service' => [
6969
'enable' => true,
70-
'file' => __DIR__.'/data/test.json',
70+
'file' => __DIR__.'/data/test.json',
7171
],
7272
]);
7373

0 commit comments

Comments
 (0)