Skip to content

Commit 229e68e

Browse files
committed
Update readme
Add detailed documents about error handling and composer usage
1 parent d0950a6 commit 229e68e

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

README.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,19 @@ numbers including floats. A few examples.
1212
* `1,234,567,890` - **One Hundred And Twenty Three Crore Forty Five Lakh Sixty Seven Thousand Eight Hundred And Ninty**
1313
* `5,024.78` - **Five Thousand Twenty Four And 78/100**
1414

15-
## Usage
15+
## Installation
16+
17+
### Using Composer
18+
19+
Navigate to your project directory and execute
20+
21+
`composer require ntwindia/ntwindia`
22+
23+
If you haven't already, include the composer `autoload.php` file.
24+
25+
```php
26+
require_once 'vendor/autoload.php';
27+
```
1628

1729
### Manual Installation
1830

@@ -27,8 +39,12 @@ git clone git@github.com:swashata/php-number-to-word-india.git
2739
```php
2840
<?php
2941
require_once 'src/NTWIndia.php';
42+
require_once 'src/Exception/NTWIndiaInvalidNumber.php';
43+
require_once 'src/Exception/NTWIndiaNumberOverflow.php';
3044
```
3145

46+
## Usage
47+
3248
**Create an instance**
3349

3450
```php
@@ -88,6 +104,21 @@ Use this when you know your number is lesser than 100 to reduce memory usage.
88104
Returns `string` The word value of the number. All of the words have uppercased
89105
first letter.
90106

107+
## Exception Handling
108+
109+
Two exceptions are thrown depending on the condition.
110+
111+
### `NTWIndia\Exception\NTWIndiaInvalidNumber`
112+
113+
If you pass a variable to a method which isn't a valid number `( ! is_numeric( $number ) )`
114+
115+
### `NTWIndia\Exception\NTWIndiaNumberOverflow`
116+
117+
If pass a number which exceeds the limit.
118+
119+
* For `numToWord` it is the `PHP_MAX_INT`.
120+
* For `numToWordSmall` it is `99`.
121+
91122
## Translation
92123

93124
To translate, kindly replace the public variables:

0 commit comments

Comments
 (0)