Skip to content

Commit

Permalink
refactor: line breaks for implode and explode
Browse files Browse the repository at this point in the history
  • Loading branch information
kryswoj committed Aug 9, 2023
1 parent 50f8aae commit 97cc5c5
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 53 deletions.
8 changes: 5 additions & 3 deletions src/Abstracts/Carrier.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,11 @@ public function addFormField(Interfaces\Fillable $field)
in_array($field->getRawName(), $this->restrictedFields, true)
) {
throw new \Exception(
'You cannot use restricted field name. Restricted names: ' . implode(
', ',
$this->restrictedFields
sprintf(
'%s %s, %s',
'You cannot use restricted field name.',
'Restricted names:',
implode(', ', $this->restrictedFields)
)
);
}
Expand Down
5 changes: 1 addition & 4 deletions src/Cli/DumpHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,7 @@ public function __invoke($args)
// Save the content.
$filesystem->put_contents(
$hooksFile,
$fileHeader . implode(
"\n",
$hookFunctions
) . "\n"
$fileHeader . implode("\n", $hookFunctions) . "\n"
);

WP_CLI::success('All hooks dumped!');
Expand Down
7 changes: 4 additions & 3 deletions src/Core/Debugging.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ public function addLog($logData = [])

if (!isset($logData['type']) || !in_array($logData['type'], $allowedTypes, true)) {
throw new \Exception(
'Log type must be a one of the following types: ' . implode(
', ',
$allowedTypes
sprintf(
'%s %s',
'Log type must be a one of the following types: ',
implode(', ', $allowedTypes)
)
);
}
Expand Down
5 changes: 1 addition & 4 deletions src/Defaults/MergeTag/Post/PostTerms.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,7 @@ public function __construct($params = [])
return '';
}

return implode(
', ',
wp_list_pluck($postTerms, 'name')
);
return implode(', ', wp_list_pluck($postTerms, 'name'));
},
]
);
Expand Down
5 changes: 1 addition & 4 deletions src/Defaults/MergeTag/User/UserRole.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ static function ($role) {
$this->trigger->{$this->getTriggerProp()}->roles
);

return implode(
', ',
$roles
);
return implode(', ', $roles);
},
]
);
Expand Down
8 changes: 1 addition & 7 deletions src/Defaults/Recipient/UserID.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,7 @@ public function parseValue($value = '')
return [];
}

$userIds = array_map(
'trim',
explode(
',',
$value
)
);
$userIds = array_map('trim', explode(',', $value));
$users = get_users(
[
'include' => $userIds,
Expand Down
5 changes: 1 addition & 4 deletions src/Defaults/Trigger/User/UserRoleChanged.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,7 @@ public function context($userId, $role, $oldRoles)
$this->userObject = $user;
$this->userMeta = get_user_meta($this->userId);
$this->newRole = $role;
$this->oldRole = implode(
', ',
$oldRoles
);
$this->oldRole = implode(', ', $oldRoles);

$this->userRegisteredDatetime = strtotime($this->userObject->user_registered);
$this->userRoleChangeDatetime = time();
Expand Down
5 changes: 1 addition & 4 deletions src/Defaults/Trigger/WordPress/UpdatesAvailable.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,7 @@ public function mergeTags()
$lists[] = __('No updates available.', 'notification');
}

return implode(
'<br><br>',
$lists
);
return implode('<br><br>', $lists);
},
'group' => __('WordPress', 'notification'),
]
Expand Down
15 changes: 3 additions & 12 deletions src/Utils/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,7 @@ public function setupFieldValues()
foreach ($this->getSections() as $sectionSlug => $section) {
foreach ($section->getGroups() as $groupSlug => $group) {
foreach ($group->getFields() as $fieldSlug => $field) {
$settingName = implode(
'/',
[$sectionSlug, $groupSlug, $fieldSlug]
);
$settingName = implode('/', [$sectionSlug, $groupSlug, $fieldSlug]);
$field->value($this->getSetting($settingName));
}
}
Expand All @@ -274,10 +271,7 @@ public function setupFieldValues()
*/
public function getSetting($setting)
{
$parts = explode(
'/',
$setting
);
$parts = explode('/', $setting);

if (count($parts) !== 3) {
throw new \Exception('You must provide exactly 3 parts as the setting name');
Expand All @@ -304,10 +298,7 @@ public function getSetting($setting)
*/
public function updateSetting($setting, $value)
{
$parts = explode(
'/',
$setting
);
$parts = explode('/', $setting);

if (count($parts) !== 3) {
throw new \Exception('You must provide exactly 3 parts as the setting name');
Expand Down
10 changes: 2 additions & 8 deletions src/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,7 @@ function notificationGetSettings()
function notificationGetSetting($setting)
{

$parts = explode(
'/',
$setting
);
$parts = explode('/', $setting);

if ($parts[0] === 'notifications') {
_deprecated_argument(
Expand All @@ -244,10 +241,7 @@ function notificationGetSetting($setting)
'The `notifications` section has been changed to `carriers`, adjust the first part of the setting.'
);
$parts[0] = 'carriers';
$setting = implode(
'/',
$parts
);
$setting = implode('/', $parts);
}

return \Notification::component('core_settings')->getSetting($setting);
Expand Down

0 comments on commit 97cc5c5

Please sign in to comment.