Skip to content

Commit b482825

Browse files
committed
Expand documentation to include DateTimeBasic examples and update NonNegativeFloat descriptions for clarity.
1 parent c0cb5b5 commit b482825

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ use PhpTypedValues\Float\FloatBasic;
5252
use PhpTypedValues\Float\NonNegativeFloat;
5353

5454
$price = FloatBasic::fromString('19.99');
55-
$ratio = new NonNegativeFloat(0.5); // > 0 required
55+
$ratio = new NonNegativeFloat(0.5); // >= 0 allowed
5656

5757
// Access the underlying scalar value / string form
5858
$ageValue = $age->value(); // 27
@@ -74,7 +74,10 @@ Provided types (so far):
7474
- NonEmptyStr — non-empty string
7575
- Floats
7676
- FloatBasic — any PHP float
77-
- PositiveFloat — positive float (> 0)
77+
- NonNegativeFloat — zero or positive float (>= 0)
78+
79+
- DateTime
80+
- DateTimeBasic — immutable DateTime value (parses common ISO-8601 formats)
7881

7982
Why
8083
---

docs/USAGE.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@ Available float types
3030
---------------------
3131

3232
- PhpTypedValues\Float\FloatBasic — any PHP float
33-
- PhpTypedValues\Float\PositiveFloat — positive float (> 0)
33+
- PhpTypedValues\Float\NonNegativeFloat — zero or positive float (>= 0)
34+
35+
Available DateTime types
36+
------------------------
37+
38+
- PhpTypedValues\DateTime\DateTimeBasic — immutable DateTime value; parses common ISO-8601 formats
3439

3540
Quick start
3641
-----------
@@ -62,7 +67,13 @@ use PhpTypedValues\Float\FloatBasic;
6267
use PhpTypedValues\Float\NonNegativeFloat;
6368

6469
$price = FloatBasic::fromString('19.99');
65-
$ratio = new NonNegativeFloat(0.5); // > 0
70+
$ratio = new NonNegativeFloat(0.5); // >= 0 allowed
71+
72+
// DateTime
73+
use PhpTypedValues\DateTime\DateTimeBasic;
74+
75+
$dt = DateTimeBasic::fromString('2025-01-02T03:04:05+00:00');
76+
echo $dt->toString(); // "2025-01-02T03:04:05+00:00"
6677

6778
// Accessing the raw value and string form
6879
echo $pos->value(); // 1
@@ -79,14 +90,16 @@ Invalid input throws an exception with a helpful message.
7990
use PhpTypedValues\Integer\PositiveInt;
8091
use PhpTypedValues\String\NonEmptyStr;
8192
use PhpTypedValues\Float\NonNegativeFloat;
93+
use PhpTypedValues\DateTime\DateTimeBasic;
8294

8395
new PositiveInt(0); // throws: Value must be a positive integer
8496
PositiveInt::fromString('12.3'); // throws: String has no valid integer
8597

8698
new NonEmptyStr(''); // throws: Value must be a non-empty string
8799

88-
new NonNegativeFloat(0.0); // throws: Value must be a positive float
89100
NonNegativeFloat::fromString('abc'); // throws: String has no valid float
101+
102+
DateTimeBasic::fromString('not-a-date'); // throws: String has no valid datetime
90103
```
91104

92105
Notes

0 commit comments

Comments
 (0)