Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bencroker committed Oct 26, 2023
1 parent 5ff8194 commit 05ad834
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Release Notes for Campaign

## 2.9.2 - Unreleased
## 2.9.2 - 2023-10-26

### Fixed

Expand Down
21 changes: 11 additions & 10 deletions src/helpers/SendoutHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ class SendoutHelper
public static function memoryInBytes(string $value): int
{
$unit = strtolower(substr($value, -1, 1));
$unitValue = match ($unit) {
'g' => pow(1024, 3),
'm' => pow(1024, 2),
'k' => 1024,
default => 1,
};

return (int)$value * match ($unit) {
'g' => pow(1024, 3),
'm' => pow(1024, 2),
'k' => 1024,
default => 1,
};
return (int)$value * $unitValue;
}

/**
Expand All @@ -34,14 +35,14 @@ public static function memoryInBytes(string $value): int
*
* @since 2.9.2
*/
public static function encodeEmojis(string $value): string
public static function encodeEmojis(?string $value): string
{
if (!Craft::$app->getDb()->getIsMysql()) {
return $value;
}

if (empty($value)) {
return $value;
return '';
}

return LitEmoji::unicodeToShortcode($value);
Expand All @@ -53,14 +54,14 @@ public static function encodeEmojis(string $value): string
*
* @since 2.9.2
*/
public static function decodeEmojis(string $value): string
public static function decodeEmojis(?string $value): string
{
if (!Craft::$app->getDb()->getIsMysql()) {
return $value;
}

if (empty($value)) {
return $value;
return '';
}

return LitEmoji::shortcodeToUnicode($value);
Expand Down

0 comments on commit 05ad834

Please sign in to comment.