Skip to content

Commit b37fb91

Browse files
author
Harry Bragg
committed
keep constructor backwards compatible
1 parent 1aaf45a commit b37fb91

File tree

7 files changed

+29
-32
lines changed

7 files changed

+29
-32
lines changed

src/Endpoint/Accounts.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,6 @@ class Accounts extends Client
8484
*/
8585
public function tfa()
8686
{
87-
return $this->clientFactory(AccountsTfa::class);
87+
return $this->endpointFactory(AccountsTfa::class);
8888
}
8989
}

src/Endpoint/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public function __call($method, $arguments)
165165
*
166166
* @return Client
167167
*/
168-
protected function clientFactory($className = self::class)
168+
protected function endpointFactory($className = self::class)
169169
{
170170
return new $className(
171171
$this->client,

src/Endpoint/Saml.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ public function getMethodNamespace()
3939
*/
4040
public function idp()
4141
{
42-
return $this->clientFactory(SamlIdp::class);
42+
return $this->endpointFactory(SamlIdp::class);
4343
}
4444
}

src/Gigya.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,18 @@ class Gigya
9191
/**
9292
* @param string $apiKey
9393
* @param string $secretKey
94+
* @param string|null $dataCenter
9495
* @param string|null $userKey
95-
* @param array $config Gigya configuration:
96-
* - dataCenter <string> (Default: DC_EU) Data Center to use
97-
* - auth <string> (Default: gigya) Type of authentication, gigya (HttpsAuth) is the
98-
* default
99-
* - uidValidator <bool> (Default: true) Include Uid Signature Validation
100-
* - factory <object> (Default: null) A ResponseFactoryInterface to use, if none is
101-
* provided ResponseFactory will be used
102-
* - guzzle <array> (Default: []) A configuration to pass to guzzle if required
103-
* - options <array> (Default: []) A set of options to pass to each request
96+
* @param array $config Gigya configuration:
97+
* - auth <string> (Default: gigya) Type of authentication, gigya (HttpsAuth) is the
98+
* default
99+
* - uidValidator <bool> (Default: true) Include Uid Signature Validation
100+
* - factory <object> (Default: null) A ResponseFactoryInterface to use, if none is
101+
* provided ResponseFactory will be used
102+
* - guzzle <array> (Default: []) A configuration to pass to guzzle if required
103+
* - options <array> (Default: []) A set of options to pass to each request
104104
*/
105-
public function __construct($apiKey, $secretKey, $userKey = null, array $config = [])
105+
public function __construct($apiKey, $secretKey, $dataCenter = null, $userKey = null, array $config = [])
106106
{
107107
$guzzleConfig = (isset($config['guzzle'])) ? $config['guzzle'] : [];
108108
$this->guzzle = new GuzzleClient($guzzleConfig);
@@ -126,7 +126,7 @@ public function __construct($apiKey, $secretKey, $userKey = null, array $config
126126
if (isset($config['factory'])) {
127127
$this->setFactory($config['factory']);
128128
}
129-
$this->dataCenter = (isset($config['dataCenter'])) ? $config['dataCenter'] : self::DC_EU;
129+
$this->dataCenter = $dataCenter ?: static::DC_EU;
130130
}
131131

132132
/**
@@ -224,7 +224,7 @@ public function __call($method, array $arguments)
224224
throw new BadMethodCallException('No Arguments should be supplied for Gigya call');
225225
}
226226

227-
return $this->clientFactory($method);
227+
return $this->endpointFactory($method);
228228
}
229229

230230
/**
@@ -233,7 +233,7 @@ public function __call($method, array $arguments)
233233
*
234234
* @return Client
235235
*/
236-
private function clientFactory($namespace, $className = Client::class)
236+
private function endpointFactory($namespace, $className = Client::class)
237237
{
238238
return new $className(
239239
$this->guzzle,
@@ -251,70 +251,70 @@ private function clientFactory($namespace, $className = Client::class)
251251
*/
252252
public function accounts()
253253
{
254-
return $this->clientFactory(static::NAMESPACE_ACCOUNTS, Accounts::class);
254+
return $this->endpointFactory(static::NAMESPACE_ACCOUNTS, Accounts::class);
255255
}
256256

257257
/**
258258
* @return Audit
259259
*/
260260
public function audit()
261261
{
262-
return $this->clientFactory(static::NAMESPACE_AUDIT, Audit::class);
262+
return $this->endpointFactory(static::NAMESPACE_AUDIT, Audit::class);
263263
}
264264

265265
/**
266266
* @return Socialize
267267
*/
268268
public function socialize()
269269
{
270-
return $this->clientFactory(static::NAMESPACE_SOCIALIZE, Socialize::class);
270+
return $this->endpointFactory(static::NAMESPACE_SOCIALIZE, Socialize::class);
271271
}
272272

273273
/**
274274
* @return Comments
275275
*/
276276
public function comments()
277277
{
278-
return $this->clientFactory(static::NAMESPACE_COMMENTS, Comments::class);
278+
return $this->endpointFactory(static::NAMESPACE_COMMENTS, Comments::class);
279279
}
280280

281281
/**
282282
* @return GameMechanics
283283
*/
284284
public function gameMechanics()
285285
{
286-
return $this->clientFactory(static::NAMESPACE_GAME_MECHANICS, GameMechanics::class);
286+
return $this->endpointFactory(static::NAMESPACE_GAME_MECHANICS, GameMechanics::class);
287287
}
288288

289289
/**
290290
* @return Reports
291291
*/
292292
public function reports()
293293
{
294-
return $this->clientFactory(static::NAMESPACE_REPORTS, Reports::class);
294+
return $this->endpointFactory(static::NAMESPACE_REPORTS, Reports::class);
295295
}
296296

297297
/**
298298
* @return DataStore
299299
*/
300300
public function dataStore()
301301
{
302-
return $this->clientFactory(static::NAMESPACE_DATA_STORE, DataStore::class);
302+
return $this->endpointFactory(static::NAMESPACE_DATA_STORE, DataStore::class);
303303
}
304304

305305
/**
306306
* @return IdentityStorage
307307
*/
308308
public function identityStorage()
309309
{
310-
return $this->clientFactory(static::NAMESPACE_IDENTITY_STORAGE, IdentityStorage::class);
310+
return $this->endpointFactory(static::NAMESPACE_IDENTITY_STORAGE, IdentityStorage::class);
311311
}
312312

313313
/**
314314
* @return Saml
315315
*/
316316
public function saml()
317317
{
318-
return $this->clientFactory(static::NAMESPACE_FIDM, Saml::class);
318+
return $this->endpointFactory(static::NAMESPACE_FIDM, Saml::class);
319319
}
320320
}

tests/functional/GigyaTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function testAuthInjectsKeyAndSecretIntoParams()
7878

7979
public function testAuthInjectsKeySecretAndUserKeyIntoParams()
8080
{
81-
$client = new Gigya('key', 'secret', 'userKey');
81+
$client = new Gigya('key', 'secret', null, 'userKey');
8282
$history = $this->setUpGigyaHistory($client);
8383

8484
$response = $client->accounts()->getAccountInfo();

tests/performance/GigyaTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function createAccountInfoHandler()
7070
];
7171
});
7272

73-
$this->gigya = new Gigya('key', 'secret', null, [
73+
$this->gigya = new Gigya('key', 'secret', null, null, [
7474
'guzzle' => [
7575
'handler' => $handler,
7676
],

tests/unit/GigyaTest.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,11 @@ public function tearDown()
6767
public function createClient($key = 'key', $secret = 'secret', $dc = Gigya::DC_EU, $userKey = null)
6868
{
6969
$options = [
70-
'dataCenter' => $dc,
7170
'uidValidator' => false,
7271
'factory' => $this->factory,
7372
];
7473

75-
return new Gigya($key, $secret, $userKey, $options);
74+
return new Gigya($key, $secret, $dc, $userKey, $options);
7675
}
7776

7877
/**
@@ -135,7 +134,6 @@ private function setupCall($fixtureName, $uri, $getOptions, $key, $secret, $user
135134

136135
public function testConstructorConfig()
137136
{
138-
139137
$this->guzzleClient->shouldReceive('__construct')
140138
->once()
141139
->with([
@@ -169,7 +167,6 @@ public function testConstructorConfig()
169167
->andReturn($gigyaResponse);
170168

171169
$config = [
172-
'dataCenter' => Gigya::DC_AU,
173170
'auth' => 'oauth',
174171
'uidValidator' => false,
175172
'factory' => $this->factory,
@@ -180,7 +177,7 @@ public function testConstructorConfig()
180177
'cert' => 'some_cert.pem',
181178
],
182179
];
183-
$client = new Gigya('key', 'secret', null, $config);
180+
$client = new Gigya('key', 'secret', Gigya::DC_AU, null, $config);
184181

185182
static::assertSame($gigyaResponse, $client->accounts()->getAccountInfo());
186183
}

0 commit comments

Comments
 (0)