Skip to content

Commit d3ee1a0

Browse files
committed
Updated documentation and documentation tests
1 parent 65e3756 commit d3ee1a0

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ By default all values are rounded to the nearest integer.
4141
```
4242
> 513 KiB
4343
44-
Increasing the precision with `setPrecision($precision)` allows the specified amount of digits after the decimal point.
44+
The default precision can be increased with `setPrecision($precision)`. Increasing the precision allows the specified amount of digits after the decimal point.
45+
4546
```php
4647
(new ByteFormatter)->setPrecision(2)->format(0x80233);
4748
```
@@ -55,6 +56,13 @@ needed.
5556
```
5657
> 512.5 KiB
5758
59+
The default precision can be overridden on a per-format basis using the optional precision argument to `format()`.
60+
61+
```php
62+
(new ByteFormatter)->setPrecision(2)->format(0x80233, 4);
63+
```
64+
> 512.5498 KiB
65+
5866
Output format
5967
-------------
6068

test/Integration/DocumentationTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ public function testPrecision()
2222
$this->assertSame('512.55 KiB', (new ByteFormatter)->setPrecision(2)->format(0x80233));
2323

2424
$this->assertSame('512.5 KiB', (new ByteFormatter)->setPrecision(2)->format(0x80200));
25+
26+
$this->assertSame('512.5498 KiB', (new ByteFormatter)->setPrecision(2)->format(0x80233, 4));
2527
}
2628

2729
public function testOutputFormat()

0 commit comments

Comments
 (0)