Skip to content

Commit f19420c

Browse files
committed
Enhance the String documentation
1 parent a3efb32 commit f19420c

27 files changed

+231
-32
lines changed

src/Integer/Alias/WeekDay.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\Integer\Alias;
6+
7+
use PhpTypedValues\Integer\IntegerWeekDay;
8+
9+
/**
10+
* @psalm-immutable
11+
*/
12+
readonly class WeekDay extends IntegerWeekDay
13+
{
14+
}

src/String/Alias/CountryCode.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@
77
use PhpTypedValues\String\StringCountryCode;
88

99
/**
10+
* Alias for ISO 3166-1 alpha‑2 country code string.
11+
*
12+
* Provides the same behavior as StringCountryCode while exposing a concise
13+
* name suitable for APIs that prefer "CountryCode".
14+
*
15+
* Example
16+
* - $c = CountryCode::fromString('US');
17+
* $c->toString(); // "US"
18+
*
1019
* @psalm-immutable
1120
*/
1221
readonly class CountryCode extends StringCountryCode

src/String/Alias/Email.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@
77
use PhpTypedValues\String\StringEmail;
88

99
/**
10+
* Alias for email address string.
11+
*
12+
* Provides the same behavior as StringEmail while exposing a concise
13+
* name suitable for APIs that prefer "Email".
14+
*
15+
* Example
16+
* - $e = Email::fromString('user@example.com');
17+
* (string) $e; // "user@example.com"
18+
*
1019
* @psalm-immutable
1120
*/
1221
readonly class Email extends StringEmail

src/String/Alias/Json.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@
77
use PhpTypedValues\String\StringJson;
88

99
/**
10+
* Alias for JSON text string.
11+
*
12+
* Provides the same behavior as StringJson while exposing a concise
13+
* name suitable for APIs that prefer "Json".
14+
*
15+
* Example
16+
* - $j = Json::fromString('{"a":1}');
17+
* $j->toArray(); // ['a' => 1]
18+
*
1019
* @psalm-immutable
1120
*/
1221
readonly class Json extends StringJson

src/String/Alias/MariaDb/Decimal.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@
77
use PhpTypedValues\String\MariaDb\StringDecimal;
88

99
/**
10+
* Alias for MariaDB DECIMAL value represented as a string.
11+
*
12+
* Provides the same behavior as StringDecimal while exposing a concise
13+
* name suitable for APIs that prefer "Decimal" in the MariaDb namespace.
14+
*
15+
* Example
16+
* - $d = Decimal::fromString('3.14');
17+
* $d->toFloat(); // 3.14 (only if exact)
18+
*
1019
* @psalm-immutable
1120
*/
1221
readonly class Decimal extends StringDecimal

src/String/Alias/MariaDb/Text.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@
77
use PhpTypedValues\String\MariaDb\StringText;
88

99
/**
10+
* Alias for MariaDB TEXT string (up to 65,535 characters).
11+
*
12+
* Provides the same behavior as StringText while exposing a concise
13+
* name suitable for APIs that prefer "Text" in the MariaDb namespace.
14+
*
15+
* Example
16+
* - $t = Text::fromString('lorem ipsum');
17+
* $t->toString(); // 'lorem ipsum'
18+
*
1019
* @psalm-immutable
1120
*/
1221
readonly class Text extends StringText

src/String/Alias/MariaDb/VarChar255.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@
77
use PhpTypedValues\String\MariaDb\StringVarChar255;
88

99
/**
10+
* Alias for MariaDB VARCHAR(255) string.
11+
*
12+
* Provides the same behavior as StringVarChar255 while exposing a concise
13+
* name suitable for APIs that prefer "VarChar255" in the MariaDb namespace.
14+
*
15+
* Example
16+
* - $v = VarChar255::fromString('Hello world');
17+
* $v->toString(); // 'Hello world'
18+
*
1019
* @psalm-immutable
1120
*/
1221
readonly class VarChar255 extends StringVarChar255

src/String/Alias/NonBlank.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@
77
use PhpTypedValues\String\StringNonBlank;
88

99
/**
10-
* Alias of Non-blank string value.
10+
* Alias for non‑blank string typed value.
1111
*
12-
* Example "hello", blank string like " " will fail.
12+
* Provides the same behavior as StringNonBlank while exposing a concise
13+
* name suitable for APIs that prefer "NonBlank".
14+
*
15+
* Example
16+
* - $v = NonBlank::fromString(' hello ');
17+
* $v->toString(); // ' hello '
1318
*
1419
* @psalm-immutable
1520
*/

src/String/Alias/NonEmpty.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@
77
use PhpTypedValues\String\StringNonEmpty;
88

99
/**
10-
* Alias of Non-empty string value.
10+
* Alias for non-empty string typed value.
1111
*
12-
* Example "hello"
12+
* Provides the same behavior as StringNonEmpty while exposing a concise
13+
* name suitable for APIs that prefer "NonEmpty".
14+
*
15+
* Example
16+
* - $v = NonEmpty::fromString('hello');
17+
* $v->value(); // 'hello'
1318
*
1419
* @psalm-immutable
1520
*/

src/String/Alias/Str.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@
77
use PhpTypedValues\String\StringStandard;
88

99
/**
10+
* Alias for the generic string typed value.
11+
*
12+
* Provides the same behavior as StringStandard while exposing a concise
13+
* name suitable for APIs that prefer "Str".
14+
*
15+
* Example
16+
* - $s = Str::fromString('hello');
17+
* $s->toString(); // "hello"
18+
*
1019
* @psalm-immutable
1120
*/
1221
readonly class Str extends StringStandard

0 commit comments

Comments
 (0)