Skip to content

Commit

Permalink
Use more helpful Readme examples
Browse files Browse the repository at this point in the history
From #1 (comment)

Examples can be improved:

- assigning to variable is not needed and is redundant (like `$spelledNumber` vs `Number::spell()`)
- instead of commenting the intent, which is clear by the class+method itself, there should be actual output
  • Loading branch information
caendesilva committed Nov 29, 2023
1 parent cf6e3ab commit 6456337
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@ composer require friendsofphp/number
use FriendsOfPhp\Number\Number;

// Format a number
$formattedNumber = Number::format(1234567.89);
echo Number::format(1234567.89); // 1,234,567.89

// Spell out a number
$spelledNumber = Number::spell(1234);
echo Number::format(1234567.89); // one thousand two hundred thirty-four

// Get the ordinal form of a number
$ordinalNumber = Number::ordinal(42);
echo Number::format(1234567.89); // 42nd

// Format a number as a percentage
$percentage = Number::percentage(0.75);
echo Number::format(1234567.89); // 1%

// Format a number as currency
$currency = Number::currency(1234.56, 'EUR');
echo Number::format(1234567.89); // €1,234.56

// Format file size
$fileSize = Number::fileSize(1024);
echo Number::format(1234567.89); // 1 KB

// Get a human-readable representation of a number
$humanReadable = Number::forHumans(1234567.89);
echo Number::format(1234567.89); // 1 million
```

### Advanced usage
Expand Down

0 comments on commit 6456337

Please sign in to comment.