From af6f9a96446b0e1c3af318b52814f3e1226a7bb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Rub=C3=A9l?= Date: Wed, 4 Oct 2023 17:36:09 +0200 Subject: [PATCH] Simplify email split (#43) * Simplify email split. * Use the value method. --- src/Collection/Complex/Email.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Collection/Complex/Email.php b/src/Collection/Complex/Email.php index a7b80f6..c32797d 100644 --- a/src/Collection/Complex/Email.php +++ b/src/Collection/Complex/Email.php @@ -10,7 +10,6 @@ namespace MichaelRubel\ValueObjects\Collection\Complex; -use Illuminate\Support\Collection; use Illuminate\Support\Facades\Validator; use Illuminate\Support\Stringable; use Illuminate\Validation\ValidationException; @@ -33,9 +32,9 @@ class Email extends Text { /** - * @var Collection + * @var array */ - protected Collection $split; + protected array $split; /** * Create a new instance of the value object. @@ -54,7 +53,7 @@ public function __construct(string|Stringable $value) */ public function username(): string { - return $this->split->first(); + return $this->split[0]; } /** @@ -62,7 +61,7 @@ public function username(): string */ public function domain(): string { - return $this->split->last(); + return $this->split[1]; } /** @@ -113,6 +112,6 @@ protected function validationRules(): array */ protected function split(): void { - $this->split = str($this->value())->split('/@/'); + $this->split = explode('@', $this->value()); } }