Skip to content

Commit 9f8004e

Browse files
committed
Document boolean typed value classes and alias updates
- Enhanced API documentation for `BoolStandard`, `TrueStandard`, and `FalseStandard` with expanded descriptions, examples, and usage scenarios. - Introduced `Boolean` alias for `BoolStandard` with updated examples and a more descriptive purpose. - Improved clarity in factory methods and formatting helper behaviors across boolean type definitions.
1 parent 98ff3ac commit 9f8004e

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed

src/Bool/Alias/Boolean.php

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

99
/**
10+
* Alias for the generic boolean typed value.
11+
*
12+
* Provides the same behavior as BoolStandard while offering a more
13+
* descriptive name for APIs that prefer "Boolean".
14+
*
15+
* Example
16+
* - $b = Boolean::fromString('true');
17+
* $b->toString(); // "true"
18+
*
1019
* @psalm-immutable
1120
*/
1221
final readonly class Boolean extends BoolStandard

src/Bool/BoolStandard.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-
* Boolean value.
15+
* Generic boolean typed value.
1616
*
17-
* Example "true"
17+
* Wraps a native bool and provides factories from strings/ints with common
18+
* true/false synonyms (case-insensitive) and convenient formatting helpers.
19+
*
20+
* Example
21+
* - $v = BoolStandard::fromString('yes');
22+
* $v->value(); // true
23+
* - $v = BoolStandard::fromInt(0);
24+
* $v->toString(); // "false"
1825
*
1926
* @psalm-immutable
2027
*/

src/Bool/FalseStandard.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,18 @@
1414
use function trim;
1515

1616
/**
17-
* Represents a literal boolean false value.
17+
* Literal boolean false typed value.
1818
*
1919
* Accepts common false-like representations in factories:
2020
* - Strings: "false", "0", "no", "off", "n" (case-insensitive)
2121
* - Ints: 0
2222
*
23+
* Example
24+
* - $f = FalseStandard::fromString('Off');
25+
* $f->value(); // false
26+
* - $f = FalseStandard::fromInt(0);
27+
* $f->toString(); // "false"
28+
*
2329
* @psalm-immutable
2430
*/
2531
readonly class FalseStandard extends BoolType

src/Bool/TrueStandard.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,18 @@
1414
use function trim;
1515

1616
/**
17-
* Represents a literal boolean true value.
17+
* Literal boolean true typed value.
1818
*
1919
* Accepts common true-like representations in factories:
2020
* - Strings: "true", "1", "yes", "on", "y" (case-insensitive)
2121
* - Ints: 1
2222
*
23+
* Example
24+
* - $t = TrueStandard::fromString('YES');
25+
* $t->value(); // true
26+
* - $t = TrueStandard::fromInt(1);
27+
* (string) $t; // "true"
28+
*
2329
* @psalm-immutable
2430
*/
2531
readonly class TrueStandard extends BoolType

0 commit comments

Comments
 (0)