michael-rubel / laravel-value-objects

A bunch of general-purpose value objects you can use in your Laravel application.
MIT License
188 stars 13 forks source link

Add `domain` and `username` methods to `Email` #19

Closed michael-rubel closed 1 year ago

michael-rubel commented 1 year ago

About

Adds handy extraction of the username and domain parts from the email.

$email = new Email('michael@laravel.software');

$email->username(); // 'michael'
$email->domain();   // 'laravel.software'
$email->toArray();  // ['email' => 'michael@laravel.software', 'username' => 'michael', 'domain' => 'laravel.software']