Add space between if and ‘(‘

[MAILPOET-1791]
This commit is contained in:
Ján Mikláš
2019-02-13 13:08:49 +01:00
committed by M. Shull
parent a935b091d3
commit 3ee58aea10
333 changed files with 4001 additions and 4001 deletions

View File

@ -12,7 +12,7 @@ use MailPoet\Subscribers\NewSubscriberNotificationMailer;
use MailPoet\Subscribers\Source;
use MailPoet\Tasks\Sending;
if(!defined('ABSPATH')) exit;
if (!defined('ABSPATH')) exit;
class API {
@ -69,19 +69,19 @@ class API {
function subscribeToLists($subscriber_id, array $segments_ids, $options = array()) {
$schedule_welcome_email = (isset($options['schedule_welcome_email']) && $options['schedule_welcome_email'] === false) ? false : true;
if(empty($segments_ids)) {
if (empty($segments_ids)) {
throw new \Exception(__('At least one segment ID is required.', 'mailpoet'));
}
// throw exception when subscriber does not exist
$subscriber = Subscriber::findOne($subscriber_id);
if(!$subscriber) {
if (!$subscriber) {
throw new \Exception(__('This subscriber does not exist.', 'mailpoet'));
}
// throw exception when none of the segments exist
$found_segments = Segment::whereIn('id', $segments_ids)->findMany();
if(!$found_segments) {
if (!$found_segments) {
$exception = _n('This list does not exist.', 'These lists do not exist.', count($segments_ids), 'mailpoet');
throw new \Exception($exception);
}
@ -89,17 +89,17 @@ class API {
// throw exception when trying to subscribe to WP Users or WooCommerce Customers segments
$found_segments_ids = array();
foreach ($found_segments as $found_segment) {
if($found_segment->type === Segment::TYPE_WP_USERS) {
if ($found_segment->type === Segment::TYPE_WP_USERS) {
throw new \Exception(__(sprintf("Can't subscribe to a WordPress Users list with ID %d.", $found_segment->id), 'mailpoet'));
}
if($found_segment->type === Segment::TYPE_WC_USERS) {
if ($found_segment->type === Segment::TYPE_WC_USERS) {
throw new \Exception(__(sprintf("Can't subscribe to a WooCommerce Customers list with ID %d.", $found_segment->id), 'mailpoet'));
}
$found_segments_ids[] = $found_segment->id;
}
// throw an exception when one or more segments do not exist
if(count($found_segments_ids) !== count($segments_ids)) {
if (count($found_segments_ids) !== count($segments_ids)) {
$missing_ids = array_values(array_diff($segments_ids, $found_segments_ids));
$exception = sprintf(
_n('List with ID %s does not exist.', 'Lists with IDs %s do not exist.', count($missing_ids), 'mailpoet'),
@ -111,7 +111,7 @@ class API {
SubscriberSegment::subscribeToSegments($subscriber, $found_segments_ids);
// schedule welcome email
if($schedule_welcome_email && $subscriber->status === Subscriber::STATUS_SUBSCRIBED) {
if ($schedule_welcome_email && $subscriber->status === Subscriber::STATUS_SUBSCRIBED) {
$this->_scheduleWelcomeNotification($subscriber, $found_segments_ids);
}
@ -123,19 +123,19 @@ class API {
}
function unsubscribeFromLists($subscriber_id, array $segments_ids) {
if(empty($segments_ids)) {
if (empty($segments_ids)) {
throw new \Exception(__('At least one segment ID is required.', 'mailpoet'));
}
// throw exception when subscriber does not exist
$subscriber = Subscriber::findOne($subscriber_id);
if(!$subscriber) {
if (!$subscriber) {
throw new \Exception(__('This subscriber does not exist.', 'mailpoet'));
}
// throw exception when none of the segments exist
$found_segments = Segment::whereIn('id', $segments_ids)->findMany();
if(!$found_segments) {
if (!$found_segments) {
$exception = _n('This list does not exist.', 'These lists do not exist.', count($segments_ids), 'mailpoet');
throw new \Exception($exception);
}
@ -143,17 +143,17 @@ class API {
// throw exception when trying to subscribe to WP Users or WooCommerce Customers segments
$found_segments_ids = array();
foreach ($found_segments as $segment) {
if($segment->type === Segment::TYPE_WP_USERS) {
if ($segment->type === Segment::TYPE_WP_USERS) {
throw new \Exception(__(sprintf("Can't unsubscribe from a WordPress Users list with ID %d.", $segment->id), 'mailpoet'));
}
if($segment->type === Segment::TYPE_WC_USERS) {
if ($segment->type === Segment::TYPE_WC_USERS) {
throw new \Exception(__(sprintf("Can't unsubscribe from a WooCommerce Customers list with ID %d.", $segment->id), 'mailpoet'));
}
$found_segments_ids[] = $segment->id;
}
// throw an exception when one or more segments do not exist
if(count($found_segments_ids) !== count($segments_ids)) {
if (count($found_segments_ids) !== count($segments_ids)) {
$missing_ids = array_values(array_diff($segments_ids, $found_segments_ids));
$exception = sprintf(
_n('List with ID %s does not exist.', 'Lists with IDs %s do not exist.', count($missing_ids), 'mailpoet'),
@ -177,14 +177,14 @@ class API {
$skip_subscriber_notification = (isset($options['skip_subscriber_notification']) && $options['skip_subscriber_notification'] === true) ? true : false;
// throw exception when subscriber email is missing
if(empty($subscriber['email'])) {
if (empty($subscriber['email'])) {
throw new \Exception(
__('Subscriber email address is required.', 'mailpoet')
);
}
// throw exception when subscriber already exists
if(Subscriber::findOne($subscriber['email'])) {
if (Subscriber::findOne($subscriber['email'])) {
throw new \Exception(
__('This subscriber already exists.', 'mailpoet')
);
@ -202,12 +202,12 @@ class API {
$new_subscriber->hydrate($default_fields);
$new_subscriber = Source::setSource($new_subscriber, Source::API);
$new_subscriber->save();
if($new_subscriber->getErrors() !== false) {
if ($new_subscriber->getErrors() !== false) {
throw new \Exception(
__(sprintf('Failed to add subscriber: %s', strtolower(implode(', ', $new_subscriber->getErrors()))), 'mailpoet')
);
}
if(!empty($custom_fields)) {
if (!empty($custom_fields)) {
$new_subscriber->saveCustomFields($custom_fields);
}
@ -215,13 +215,13 @@ class API {
$new_subscriber = Subscriber::findOne($new_subscriber->id);
// subscribe to segments and optionally: 1) send confirmation email, 2) schedule welcome email(s)
if(!empty($segments)) {
if (!empty($segments)) {
$this->subscribeToLists($new_subscriber->id, $segments);
// send confirmation email
if($send_confirmation_email && $new_subscriber->status === Subscriber::STATUS_UNCONFIRMED) {
if ($send_confirmation_email && $new_subscriber->status === Subscriber::STATUS_UNCONFIRMED) {
$result = $this->_sendConfirmationEmail($new_subscriber);
if(!$result && $new_subscriber->getErrors()) {
if (!$result && $new_subscriber->getErrors()) {
throw new \Exception(
__(sprintf('Subscriber added, but confirmation email failed to send: %s', strtolower(implode(', ', $new_subscriber->getErrors()))), 'mailpoet')
);
@ -229,11 +229,11 @@ class API {
}
// schedule welcome email(s)
if($schedule_welcome_email && $new_subscriber->status === Subscriber::STATUS_SUBSCRIBED) {
if ($schedule_welcome_email && $new_subscriber->status === Subscriber::STATUS_SUBSCRIBED) {
$this->_scheduleWelcomeNotification($new_subscriber, $segments);
}
if(!$skip_subscriber_notification) {
if (!$skip_subscriber_notification) {
$this->sendSubscriberNotification($new_subscriber, $segments);
}
}
@ -242,14 +242,14 @@ class API {
function addList(array $list) {
// throw exception when list name is missing
if(empty($list['name'])) {
if (empty($list['name'])) {
throw new \Exception(
__('List name is required.', 'mailpoet')
);
}
// throw exception when list already exists
if(Segment::where('name', $list['name'])->findOne()) {
if (Segment::where('name', $list['name'])->findOne()) {
throw new \Exception(
__('This list already exists.', 'mailpoet')
);
@ -259,7 +259,7 @@ class API {
$new_list = Segment::create();
$new_list->hydrate($list);
$new_list->save();
if($new_list->getErrors() !== false) {
if ($new_list->getErrors() !== false) {
throw new \Exception(
__(sprintf('Failed to add list: %s', strtolower(implode(', ', $new_list->getErrors()))), 'mailpoet')
);
@ -274,7 +274,7 @@ class API {
function getSubscriber($subscriber_email) {
$subscriber = Subscriber::findOne($subscriber_email);
// throw exception when subscriber does not exist
if(!$subscriber) {
if (!$subscriber) {
throw new \Exception(__('This subscriber does not exist.', 'mailpoet'));
}
return $subscriber->withCustomFields()->withSubscriptions()->asArray();
@ -286,9 +286,9 @@ class API {
protected function _scheduleWelcomeNotification(Subscriber $subscriber, array $segments) {
$result = Scheduler::scheduleSubscriberWelcomeNotification($subscriber->id, $segments);
if(is_array($result)) {
if (is_array($result)) {
foreach ($result as $queue) {
if($queue instanceof Sending && $queue->getErrors()) {
if ($queue instanceof Sending && $queue->getErrors()) {
throw new \Exception(
__(sprintf('Subscriber added, but welcome email failed to send: %s', strtolower(implode(', ', $queue->getErrors()))), 'mailpoet')
);