Skip to content

Commit 85e1d6d

Browse files
committed
Add Email alias for StringEmail with usage example
- Introduced `Email` as a readonly alias for `StringEmail`. - Updated `Usage` examples to demonstrate `Email` usage and behavior.
1 parent 349540d commit 85e1d6d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/String/Alias/Email.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace PhpTypedValues\String\Alias;
6+
7+
use PhpTypedValues\String\StringEmail;
8+
9+
/**
10+
* @psalm-immutable
11+
*/
12+
readonly class Email extends StringEmail
13+
{
14+
}

src/Usage/String.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
use PhpTypedValues\String\Alias\Email;
34
use PhpTypedValues\String\Alias\JsonStr;
45
use PhpTypedValues\String\Alias\NonBlankStr;
56
use PhpTypedValues\String\Alias\NonEmptyStr;
@@ -44,6 +45,7 @@
4445
echo Json::tryFromString('{}')->toString() . \PHP_EOL;
4546

4647
// Email (usage and try* for Psalm visibility)
48+
echo Email::fromString('User@Example.COM')->toString() . \PHP_EOL; // normalized to lowercase
4749
echo StringEmail::fromString('User@Example.COM')->toString() . \PHP_EOL; // normalized to lowercase
4850
$em = StringEmail::tryFromString('not-an-email');
4951
if (!($em instanceof Undefined)) {

0 commit comments

Comments
 (0)