Skip to content

Commit

Permalink
Simplify email split (#43)
Browse files Browse the repository at this point in the history
* Simplify email split.

* Use the value method.
  • Loading branch information
michael-rubel authored Oct 4, 2023
1 parent d03dd96 commit af6f9a9
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/Collection/Complex/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -33,9 +32,9 @@
class Email extends Text
{
/**
* @var Collection<int, string>
* @var array<int, string>
*/
protected Collection $split;
protected array $split;

/**
* Create a new instance of the value object.
Expand All @@ -54,15 +53,15 @@ public function __construct(string|Stringable $value)
*/
public function username(): string
{
return $this->split->first();
return $this->split[0];
}

/**
* @return string
*/
public function domain(): string
{
return $this->split->last();
return $this->split[1];
}

/**
Expand Down Expand Up @@ -113,6 +112,6 @@ protected function validationRules(): array
*/
protected function split(): void
{
$this->split = str($this->value())->split('/@/');
$this->split = explode('@', $this->value());
}
}

0 comments on commit af6f9a9

Please sign in to comment.