Skip to content

Commit a3efb32

Browse files
committed
Expand API documentation for integer-typed value classes and aliases
- Enhanced documentation for `IntegerStandard`, `IntegerNonNegative`, `IntegerPositive`, `IntegerWeekDay`, `IntegerTiny`, and other integer classes, clarifying behavior, validation, and formatting. - Documented aliases including `Positive`, `NonNegative`, `IntType`, `Id`, `Tiny`, and `Integer`, with updated examples demonstrating usage and purpose. - Improved clarity around factory methods, validation mechanisms, and example scenarios across integer type definitions. - Standardized descriptions for range-specific and domain-specific integer implementations.
1 parent e2096ba commit a3efb32

File tree

11 files changed

+103
-15
lines changed

11 files changed

+103
-15
lines changed

src/Integer/Alias/Id.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,17 @@
77
use PhpTypedValues\Integer\IntegerPositive;
88

99
/**
10-
* Alias of Positive integer used as identifier.
10+
* Alias for positive integer used as identifier.
1111
*
12-
* Example "42"
12+
* Provides the same behavior as IntegerPositive but conveys the semantic
13+
* meaning of an application-level identifier. Useful where IDs are strictly
14+
* positive integers.
15+
*
16+
* Example
17+
* - $id = Id::fromString('42');
18+
* $id->value(); // 42
19+
* - $id = Id::fromInt(7);
20+
* (string) $id; // "7"
1321
*
1422
* @psalm-immutable
1523
*/

src/Integer/Alias/IntType.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@
77
use PhpTypedValues\Integer\IntegerStandard;
88

99
/**
10+
* Alias for the generic integer-typed value.
11+
*
12+
* Provides the same behavior as IntegerStandard while offering a more
13+
* descriptive name for APIs that prefer "IntType".
14+
*
15+
* Example
16+
* - $v = IntType::fromString('7');
17+
* $v->toString(); // "7"
18+
* - $v = IntType::fromInt(42);
19+
* (string) $v; // "42"
20+
*
1021
* @psalm-immutable
1122
*/
1223
readonly class IntType extends IntegerStandard

src/Integer/Alias/Integer.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@
77
use PhpTypedValues\Integer\IntegerStandard;
88

99
/**
10+
* Alias for the generic integer-typed value.
11+
*
12+
* Provides the same behavior as IntegerStandard while offering a concise
13+
* descriptive name for APIs that prefer "Integer".
14+
*
15+
* Example
16+
* - $v = Integer::fromString('7');
17+
* $v->toString(); // "7"
18+
* - $v = Integer::fromInt(42);
19+
* (string) $v; // "42"
20+
*
1021
* @psalm-immutable
1122
*/
1223
readonly class Integer extends IntegerStandard

src/Integer/Alias/MariaDb/Tiny.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,16 @@
77
use PhpTypedValues\Integer\MariaDb\IntegerTiny;
88

99
/**
10-
* Alias of IntTiny.
10+
* Alias for MariaDB tiny integer type (signed TINYINT: -128..127).
1111
*
12-
* Example "1"
12+
* Provides the same behavior as IntegerTiny while exposing a concise name
13+
* suitable for APIs that prefer "Tiny" in the MariaDB namespace.
14+
*
15+
* Example
16+
* - $v = Tiny::fromInt(1);
17+
* $v->value(); // 1
18+
* - $v = Tiny::fromString('-5');
19+
* (string) $v; // "-5"
1320
*
1421
* @psalm-immutable
1522
*/

src/Integer/Alias/NonNegative.php

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

99
/**
10-
* Alias of Non-negative integer (>= 0).
10+
* Alias for non‑negative integer (>= 0).
1111
*
12-
* Example "0"
12+
* Provides the same behavior as IntegerNonNegative while exposing a concise
13+
* name suitable for APIs that prefer "NonNegative".
14+
*
15+
* Example
16+
* - $v = NonNegative::fromString('0');
17+
* $v->value(); // 0
18+
* - $v = NonNegative::fromInt(10);
19+
* (string) $v; // "10"
1320
*
1421
* @psalm-immutable
1522
*/

src/Integer/Alias/Positive.php

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

99
/**
10-
* Alias of Positive integer (> 0).
10+
* Alias for positive integer (> 0).
1111
*
12-
* Example "1"
12+
* Provides the same behavior as IntegerPositive while exposing a concise
13+
* name suitable for APIs that prefer "Positive".
14+
*
15+
* Example
16+
* - $v = Positive::fromString('1');
17+
* $v->value(); // 1
18+
* - $v = Positive::fromInt(5);
19+
* (string) $v; // "5"
1320
*
1421
* @psalm-immutable
1522
*/

src/Integer/IntegerNonNegative.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,16 @@
1212
use function sprintf;
1313

1414
/**
15-
* Non-negative integer (>= 0).
15+
* Nonnegative integer (>= 0).
1616
*
17-
* Example "0"
17+
* Guarantees the wrapped integer is zero or positive. Provides factories from
18+
* strictly validated string and native int, along with standard formatting.
19+
*
20+
* Example
21+
* - $v = IntegerNonNegative::fromString('0');
22+
* $v->value(); // 0 (int)
23+
* - $v = IntegerNonNegative::fromInt(10);
24+
* (string) $v; // "10"
1825
*
1926
* @psalm-immutable
2027
*/

src/Integer/IntegerPositive.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@
1414
/**
1515
* Positive integer (> 0).
1616
*
17-
* Example "1"
17+
* Ensures the wrapped value is strictly greater than zero. Provides factories
18+
* from strictly validated string and native int, plus convenient formatting.
19+
*
20+
* Example
21+
* - $v = IntegerPositive::fromString('1');
22+
* $v->value(); // 1 (int)
23+
* - $v = IntegerPositive::fromInt(5);
24+
* (string) $v; // "5"
1825
*
1926
* @psalm-immutable
2027
*/

src/Integer/IntegerStandard.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,16 @@
1010
use PhpTypedValues\Undefined\Alias\Undefined;
1111

1212
/**
13-
* Represents any PHP integer.
13+
* Generic integer-typed value.
1414
*
15-
* Example "-10"
15+
* Wraps any PHP integer and provides factories from a strictly validated
16+
* string or a native int, along with convenient string formatting.
17+
*
18+
* Example
19+
* - $v = IntegerStandard::fromString('-10');
20+
* $v->value(); // -10 (int)
21+
* - $v = IntegerStandard::fromInt(42);
22+
* (string) $v; // "42"
1623
*
1724
* @psalm-immutable
1825
*/

src/Integer/IntegerWeekDay.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,15 @@
1414
/**
1515
* Week day number between 1 and 7.
1616
*
17-
* Example "5"
17+
* Represents an integer constrained to the inclusive range 1..7 where
18+
* 1 = Monday and 7 = Sunday (or any convention your domain applies).
19+
* Factories accept strictly validated strings and native ints.
20+
*
21+
* Example
22+
* - $v = IntegerWeekDay::fromString('5');
23+
* $v->value(); // 5
24+
* - $v = IntegerWeekDay::fromInt(1);
25+
* (string) $v; // "1"
1826
*
1927
* @psalm-immutable
2028
*/

0 commit comments

Comments
 (0)