refactor: ♻️ replace trim with mb_trim
This commit is contained in:
parent
e108c5bf66
commit
eb1d372b2f
18 changed files with 18 additions and 42 deletions
|
|
@ -9,9 +9,7 @@ final readonly class ActorDisplayName
|
|||
public function __construct(
|
||||
public string $value,
|
||||
) {
|
||||
$trimmed = mb_trim($value);
|
||||
|
||||
if ($trimmed === '') {
|
||||
if (mb_trim($this->value) === '') {
|
||||
throw new \DomainException('Display name cannot be empty.');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ final readonly class BrandName
|
|||
public function __construct(
|
||||
public string $value,
|
||||
) {
|
||||
$trimmed = trim($value);
|
||||
$trimmed = mb_trim($value);
|
||||
|
||||
if ($trimmed === '') {
|
||||
throw new \DomainException('Brand name cannot be empty.');
|
||||
|
|
|
|||
|
|
@ -9,9 +9,7 @@ final readonly class CampaignCode
|
|||
public function __construct(
|
||||
public string $code,
|
||||
) {
|
||||
$trimmed = mb_trim($code);
|
||||
|
||||
if ($trimmed === '') {
|
||||
if (mb_trim($this->code) === '') {
|
||||
throw new \DomainException('Campaign code cannot be empty.');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,9 +9,7 @@ final readonly class CampaignName
|
|||
public function __construct(
|
||||
public string $value,
|
||||
) {
|
||||
$trimmed = mb_trim($value);
|
||||
|
||||
if ($trimmed === '') {
|
||||
if (mb_trim($this->value) === '') {
|
||||
throw new \DomainException('Campaign name cannot be empty.');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,9 +9,7 @@ final readonly class RejectionReason
|
|||
public function __construct(
|
||||
public string $value,
|
||||
) {
|
||||
$trimmed = mb_trim($value);
|
||||
|
||||
if ($trimmed === '') {
|
||||
if (mb_trim($this->value) === '') {
|
||||
throw new \DomainException('Rejection reason cannot be empty.');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,9 +13,7 @@ final readonly class CouponLegalInformation implements Equatable
|
|||
public string $legalText,
|
||||
public Country $forLocale
|
||||
) {
|
||||
$trimmed = mb_trim($this->legalText);
|
||||
|
||||
if ($trimmed === '') {
|
||||
if (mb_trim($this->legalText) === '') {
|
||||
throw new \DomainException('Legal text cannot be empty.');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,9 +15,7 @@ final readonly class CouponProduct
|
|||
/** @var CouponProductInfo[] */
|
||||
public array $labels,
|
||||
) {
|
||||
$trimmed = mb_trim($this->name);
|
||||
|
||||
if ($trimmed === '') {
|
||||
if (mb_trim($this->name) === '') {
|
||||
throw new \DomainException('Coupon Product name cannot be empty.');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,9 +9,7 @@ final readonly class CouponName
|
|||
public function __construct(
|
||||
public string $value,
|
||||
) {
|
||||
$trimmed = mb_trim($value);
|
||||
|
||||
if ($trimmed === '') {
|
||||
if (mb_trim($this->value) === '') {
|
||||
throw new \DomainException('Coupon name cannot be empty.');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,9 +9,7 @@ final readonly class CouponProductName
|
|||
public function __construct(
|
||||
public string $value,
|
||||
) {
|
||||
$trimmed = mb_trim($value);
|
||||
|
||||
if ($trimmed === '') {
|
||||
if (mb_trim($this->value) === '') {
|
||||
throw new \DomainException('Coupon product name cannot be empty.');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,9 +13,7 @@ final readonly class GS1 implements \Stringable, Equatable
|
|||
public string $value,
|
||||
public BarcodeFormat $format
|
||||
) {
|
||||
$trimmed = mb_trim($this->value);
|
||||
|
||||
if ($trimmed === '') {
|
||||
if (mb_trim($this->value) === '') {
|
||||
throw new \DomainException('GS1 value cannot be empty.');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ final readonly class PicturePath implements \Stringable, Equatable
|
|||
public function __construct(
|
||||
public string $value,
|
||||
) {
|
||||
$trimmed = trim($this->value);
|
||||
$trimmed = mb_trim($this->value);
|
||||
|
||||
if ($trimmed === '') {
|
||||
throw new \DomainException('Picture Path cannot be empty.');
|
||||
|
|
|
|||
|
|
@ -11,9 +11,7 @@ final readonly class ProcessingCode implements \Stringable, Equatable
|
|||
public function __construct(
|
||||
public string $value,
|
||||
) {
|
||||
$trimmed = mb_trim($this->value);
|
||||
|
||||
if ($trimmed === '') {
|
||||
if (mb_trim($this->value) === '') {
|
||||
throw new \DomainException('Processing Code value cannot be empty.');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,9 +18,7 @@ final readonly class StockAdjustment
|
|||
throw new \DomainException('Stock Amount should be more than 0.');
|
||||
}
|
||||
|
||||
$trimmed = mb_trim($reason);
|
||||
|
||||
if ($trimmed === '') {
|
||||
if (mb_trim($this->reason) === '') {
|
||||
throw new \DomainException('Reason cannot be empty.');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,9 +9,7 @@ final readonly class TagName
|
|||
public function __construct(
|
||||
public string $value,
|
||||
) {
|
||||
$trimmed = mb_trim($value);
|
||||
|
||||
if ($trimmed === '') {
|
||||
if (mb_trim($this->value) === '') {
|
||||
throw new \DomainException('Tag name cannot be empty.');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ abstract readonly class EntityId implements \Stringable, Equatable
|
|||
public function __construct(
|
||||
public string $value
|
||||
) {
|
||||
if (trim($value) === '') {
|
||||
if (mb_trim($this->value) === '') {
|
||||
throw new \DomainException('EntityId value cannot be empty');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ final class DatesHelper
|
|||
|
||||
public static function parseDateTime(string $datetime): \DateTimeInterface
|
||||
{
|
||||
$datetime = trim($datetime);
|
||||
$datetime = mb_trim($datetime);
|
||||
|
||||
if ($datetime === '') {
|
||||
throw InvalidDateFormatException::forDateString($datetime);
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ final readonly class Email implements \Stringable, Equatable
|
|||
public function __construct(
|
||||
string $value,
|
||||
) {
|
||||
$trimmed = trim($value);
|
||||
$trimmed = mb_trim($value);
|
||||
|
||||
if ($trimmed === '') {
|
||||
throw new \DomainException('Email cannot be empty.');
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ final readonly class Rcs implements \Stringable, Equatable
|
|||
public function __construct(
|
||||
public string $value,
|
||||
) {
|
||||
$trimmed = trim($this->value);
|
||||
$trimmed = mb_trim($this->value);
|
||||
|
||||
if ($trimmed === '') {
|
||||
throw new \DomainException('Rcs text cannot be empty.');
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue