Skip to content

Commit af6f9a9

Browse files
Simplify email split (#43)
* Simplify email split. * Use the value method.
1 parent d03dd96 commit af6f9a9

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/Collection/Complex/Email.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
namespace MichaelRubel\ValueObjects\Collection\Complex;
1212

13-
use Illuminate\Support\Collection;
1413
use Illuminate\Support\Facades\Validator;
1514
use Illuminate\Support\Stringable;
1615
use Illuminate\Validation\ValidationException;
@@ -33,9 +32,9 @@
3332
class Email extends Text
3433
{
3534
/**
36-
* @var Collection<int, string>
35+
* @var array<int, string>
3736
*/
38-
protected Collection $split;
37+
protected array $split;
3938

4039
/**
4140
* Create a new instance of the value object.
@@ -54,15 +53,15 @@ public function __construct(string|Stringable $value)
5453
*/
5554
public function username(): string
5655
{
57-
return $this->split->first();
56+
return $this->split[0];
5857
}
5958

6059
/**
6160
* @return string
6261
*/
6362
public function domain(): string
6463
{
65-
return $this->split->last();
64+
return $this->split[1];
6665
}
6766

6867
/**
@@ -113,6 +112,6 @@ protected function validationRules(): array
113112
*/
114113
protected function split(): void
115114
{
116-
$this->split = str($this->value())->split('/@/');
115+
$this->split = explode('@', $this->value());
117116
}
118117
}

0 commit comments

Comments
 (0)