Commit 32159331 authored by wwccw0591's avatar wwccw0591

pc

parent 9f5eecd2
......@@ -70,7 +70,7 @@ class PushPayload {
$this->addAllAudience();
return $this;
} else {
throw new InvalidArgumentException('Invalid audience value');
throw new \InvalidArgumentException('Invalid audience value');
}
}
......@@ -115,7 +115,7 @@ class PushPayload {
if (is_array($value)) {
foreach($value as $v) {
if (!is_string($v)) {
throw new InvalidArgumentException("Invalid $name value");
throw new \InvalidArgumentException("Invalid $name value");
}
if (!in_array($v, $this->$key)) {
array_push($this->$key, $v);
......@@ -126,7 +126,7 @@ class PushPayload {
array_push($this->$key, $value);
}
} else {
throw new InvalidArgumentException("Invalid $name value");
throw new \InvalidArgumentException("Invalid $name value");
}
return $this;
......@@ -134,7 +134,7 @@ class PushPayload {
public function setNotificationAlert($alert) {
if (!is_string($alert)) {
throw new InvalidArgumentException("Invalid alert value");
throw new \InvalidArgumentException("Invalid alert value");
}
$this->notificationAlert = $alert;
return $this;
......@@ -145,14 +145,14 @@ class PushPayload {
if (!is_null($alert)) {
if (!is_string($alert)) {
throw new InvalidArgumentException("Invalid winphone notification");
throw new \InvalidArgumentException("Invalid winphone notification");
}
$winPhone['alert'] = $alert;
}
if (!is_null($title)) {
if (!is_string($title)) {
throw new InvalidArgumentException("Invalid winphone title notification");
throw new \InvalidArgumentException("Invalid winphone title notification");
}
if(strlen($title) > 0) {
$winPhone['title'] = $title;
......@@ -161,7 +161,7 @@ class PushPayload {
if (!is_null($_open_page)) {
if (!is_string($_open_page)) {
throw new InvalidArgumentException("Invalid winphone _open_page notification");
throw new \InvalidArgumentException("Invalid winphone _open_page notification");
}
if (strlen($_open_page) > 0) {
$winPhone['_open_page'] = $_open_page;
......@@ -170,7 +170,7 @@ class PushPayload {
if (!is_null($extras)) {
if (!is_array($extras)) {
throw new InvalidArgumentException("Invalid winphone extras notification");
throw new \InvalidArgumentException("Invalid winphone extras notification");
}
if (count($extras) > 0) {
$winPhone['extras'] = $extras;
......@@ -178,7 +178,7 @@ class PushPayload {
}
if (count($winPhone) <= 0) {
throw new InvalidArgumentException("Invalid winphone notification");
throw new \InvalidArgumentException("Invalid winphone notification");
}
$this->winPhoneNotification = $winPhone;
......@@ -203,7 +203,7 @@ class PushPayload {
// validate platform
if (is_null($this->platform)) {
throw new InvalidArgumentException("platform must be set");
throw new \InvalidArgumentException("platform must be set");
}
$payload["platform"] = $this->platform;
......@@ -235,9 +235,9 @@ class PushPayload {
$audience["abtest"] = $this->abtests;
}
if (is_null($this->audience) && count($audience) <= 0) {
throw new InvalidArgumentException("audience must be set");
throw new \InvalidArgumentException("audience must be set");
} else if (!is_null($this->audience) && count($audience) > 0) {
throw new InvalidArgumentException("you can't add tags/alias/registration_id/tag_and when audience='all'");
throw new \InvalidArgumentException("you can't add tags/alias/registration_id/tag_and when audience='all'");
} else if (is_null($this->audience)) {
$payload["audience"] = $audience;
} else {
......@@ -256,7 +256,7 @@ class PushPayload {
$notification['android'] = $this->androidNotification;
if (is_null($this->androidNotification['alert'])) {
if (is_null($this->notificationAlert)) {
throw new InvalidArgumentException("Android alert can not be null");
throw new \InvalidArgumentException("Android alert can not be null");
} else {
$notification['android']['alert'] = $this->notificationAlert;
}
......@@ -267,7 +267,7 @@ class PushPayload {
$notification['ios'] = $this->iosNotification;
if (is_null($this->iosNotification['alert'])) {
if (is_null($this->notificationAlert)) {
throw new InvalidArgumentException("iOS alert can not be null");
throw new \InvalidArgumentException("iOS alert can not be null");
} else {
$notification['ios']['alert'] = $this->notificationAlert;
}
......@@ -278,7 +278,7 @@ class PushPayload {
$notification['winphone'] = $this->winPhoneNotification;
if (is_null($this->winPhoneNotification['alert'])) {
if (is_null($this->winPhoneNotification)) {
throw new InvalidArgumentException("WinPhone alert can not be null");
throw new \InvalidArgumentException("WinPhone alert can not be null");
} else {
$notification['winphone']['alert'] = $this->notificationAlert;
}
......@@ -293,7 +293,7 @@ class PushPayload {
$payload['message'] = $this->message;
}
if (!array_key_exists('notification', $payload) && !array_key_exists('message', $payload)) {
throw new InvalidArgumentException('notification and message can not all be null');
throw new \InvalidArgumentException('notification and message can not all be null');
}
if (!is_null($this->smsMessage)) {
......@@ -466,14 +466,14 @@ class PushPayload {
if (!is_null($alert)) {
if (!is_string($alert) && !is_array($alert)) {
throw new InvalidArgumentException("Invalid ios alert value");
throw new \InvalidArgumentException("Invalid ios alert value");
}
$ios['alert'] = $alert;
}
if (!is_null($sound)) {
if (!is_string($sound)) {
throw new InvalidArgumentException("Invalid ios sound value");
throw new \InvalidArgumentException("Invalid ios sound value");
}
if ($sound !== Config::DISABLE_SOUND) {
$ios['sound'] = $sound;
......@@ -486,7 +486,7 @@ class PushPayload {
if (!is_null($badge)) {
if (is_string($badge) && !preg_match("/^[+-]{1}[0-9]{1,3}$/", $badge)) {
if (!is_int($badge)) {
throw new InvalidArgumentException("Invalid ios badge value");
throw new \InvalidArgumentException("Invalid ios badge value");
}
}
if ($badge != Config::DISABLE_BADGE) {
......@@ -499,14 +499,14 @@ class PushPayload {
if (!is_null($content_available)) {
if (!is_bool($content_available)) {
throw new InvalidArgumentException("Invalid ios content-available value");
throw new \InvalidArgumentException("Invalid ios content-available value");
}
$ios['content-available'] = $content_available;
}
if (!is_null($category)) {
if (!is_string($category)) {
throw new InvalidArgumentException("Invalid ios category value");
throw new \InvalidArgumentException("Invalid ios category value");
}
if (strlen($category)) {
$ios['category'] = $category;
......@@ -515,7 +515,7 @@ class PushPayload {
if (!is_null($extras)) {
if (!is_array($extras)) {
throw new InvalidArgumentException("Invalid ios extras value");
throw new \InvalidArgumentException("Invalid ios extras value");
}
if (count($extras) > 0) {
$ios['extras'] = $extras;
......@@ -523,7 +523,7 @@ class PushPayload {
}
if (count($ios) <= 0) {
throw new InvalidArgumentException("Invalid iOS notification");
throw new \InvalidArgumentException("Invalid iOS notification");
}
$this->iosNotification = $ios;
......@@ -535,14 +535,14 @@ class PushPayload {
if (!is_null($alert)) {
if (!is_string($alert)) {
throw new InvalidArgumentException("Invalid android alert value");
throw new \InvalidArgumentException("Invalid android alert value");
}
$android['alert'] = $alert;
}
if (!is_null($title)) {
if(!is_string($title)) {
throw new InvalidArgumentException("Invalid android title value");
throw new \InvalidArgumentException("Invalid android title value");
}
if(strlen($title) > 0) {
$android['title'] = $title;
......@@ -551,14 +551,14 @@ class PushPayload {
if (!is_null($builderId)) {
if (!is_int($builderId)) {
throw new InvalidArgumentException("Invalid android builder_id value");
throw new \InvalidArgumentException("Invalid android builder_id value");
}
$android['builder_id'] = $builderId;
}
if (!is_null($extras)) {
if (!is_array($extras)) {
throw new InvalidArgumentException("Invalid android extras value");
throw new \InvalidArgumentException("Invalid android extras value");
}
if (count($extras) > 0) {
$android['extras'] = $extras;
......@@ -566,7 +566,7 @@ class PushPayload {
}
if (count($android) <= 0) {
throw new InvalidArgumentException("Invalid android notification");
throw new \InvalidArgumentException("Invalid android notification");
}
$this->androidNotification = $android;
......@@ -577,28 +577,28 @@ class PushPayload {
$message = array();
if (is_null($msg_content) || !is_string($msg_content)) {
throw new InvalidArgumentException("Invalid message content");
throw new \InvalidArgumentException("Invalid message content");
} else {
$message['msg_content'] = $msg_content;
}
if (!is_null($title)) {
if (!is_string($title)) {
throw new InvalidArgumentException("Invalid message title");
throw new \InvalidArgumentException("Invalid message title");
}
$message['title'] = $title;
}
if (!is_null($content_type)) {
if (!is_string($content_type)) {
throw new InvalidArgumentException("Invalid message content type");
throw new \InvalidArgumentException("Invalid message content type");
}
$message["content_type"] = $content_type;
}
if (!is_null($extras)) {
if (!is_array($extras)) {
throw new InvalidArgumentException("Invalid message extras");
throw new \InvalidArgumentException("Invalid message extras");
}
if (count($extras) > 0) {
$message['extras'] = $extras;
......@@ -614,7 +614,7 @@ class PushPayload {
if (is_string($content) && mb_strlen($content) < 480) {
$sms['content'] = $content;
} else {
throw new InvalidArgumentException('Invalid sms content, sms content\'s length must in [0, 480]');
throw new \InvalidArgumentException('Invalid sms content, sms content\'s length must in [0, 480]');
}
$sms['delay_time'] = ($delay_time === 0 || (is_int($delay_time) && $delay_time > 0 && $delay_time <= 86400)) ? $delay_time : 0;
......@@ -628,7 +628,7 @@ class PushPayload {
if (!is_null($sendno)) {
if (!is_int($sendno)) {
throw new InvalidArgumentException('Invalid option sendno');
throw new \InvalidArgumentException('Invalid option sendno');
}
$options['sendno'] = $sendno;
} else {
......@@ -637,21 +637,21 @@ class PushPayload {
if (!is_null($time_to_live)) {
if (!is_int($time_to_live) || $time_to_live < 0 || $time_to_live > 864000) {
throw new InvalidArgumentException('Invalid option time to live, it must be a int and in [0, 864000]');
throw new \InvalidArgumentException('Invalid option time to live, it must be a int and in [0, 864000]');
}
$options['time_to_live'] = $time_to_live;
}
if (!is_null($override_msg_id)) {
if (!is_long($override_msg_id)) {
throw new InvalidArgumentException('Invalid option override msg id');
throw new \InvalidArgumentException('Invalid option override msg id');
}
$options['override_msg_id'] = $override_msg_id;
}
if (!is_null($apns_production)) {
if (!is_bool($apns_production)) {
throw new InvalidArgumentException('Invalid option apns production');
throw new \InvalidArgumentException('Invalid option apns production');
}
$options['apns_production'] = $apns_production;
} else {
......@@ -660,7 +660,7 @@ class PushPayload {
if (!is_null($big_push_duration)) {
if (!is_int($big_push_duration) || $big_push_duration < 0 || $big_push_duration > 1440) {
throw new InvalidArgumentException('Invalid option big push duration, it must be a int and in [0, 1440]');
throw new \InvalidArgumentException('Invalid option big push duration, it must be a int and in [0, 1440]');
}
$options['big_push_duration'] = $big_push_duration;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment