Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify email split #43

Merged
merged 2 commits into from
Oct 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
}
}
Loading