Skip to content

Commit 64a66e0

Browse files
authored
Merge pull request #17 from chrisharrison/master
Fixed an incorrect return type and removed restriction on optional parameter
2 parents 9ffc9d5 + f6bdf1d commit 64a66e0

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

lib/AmazonSNS.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -439,19 +439,24 @@ public function unsubscribe($subscriptionArn) {
439439
* @param string $platformApplicationArn
440440
* @param string $token
441441
* @param string $userData
442-
* @return bool
442+
* @return string
443443
* @throws InvalidArgumentException
444444
*/
445-
public function createPlatformEndpoint($platformApplicationArn, $token, $userData) {
446-
if(empty($platformApplicationArn) || empty($token) || empty($userData)) {
447-
throw new InvalidArgumentException('Must supply a PlatformApplicationArn,Token & UserData to create platform endpoint');
445+
public function createPlatformEndpoint($platformApplicationArn, $token, $userData = null) {
446+
if(empty($platformApplicationArn) || empty($token)) {
447+
throw new InvalidArgumentException('Must supply a PlatformApplicationArn & Token to create platform endpoint');
448448
}
449449

450-
$response = $this->_request('CreatePlatformEndpoint', array(
450+
$attributes = array(
451451
'PlatformApplicationArn' => $platformApplicationArn,
452-
'Token' => $token,
453-
'CustomUserData' => $userData
454-
));
452+
'Token' => $token
453+
);
454+
455+
if(!empty($userData)) {
456+
$attributes['CustomUserData'] = $userData;
457+
}
458+
459+
$response = $this->_request('CreatePlatformEndpoint', $attributes);
455460

456461
return strval($response->CreatePlatformEndpointResult->EndpointArn);
457462
}

0 commit comments

Comments
 (0)