Skip to content

Commit 936b365

Browse files
committed
Change methods and variables to PSR2
Also add the travis and codeclimate configuration.
1 parent 7a10451 commit 936b365

File tree

11 files changed

+1737
-162
lines changed

11 files changed

+1737
-162
lines changed

.codeclimate.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
languages:
2+
PHP: true
3+
exclude_paths: ["tests/*"]

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
vendor
2-
composer.lock
2+
build

.travis.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Tell Travis CI we are using PHP
2+
language: php
3+
4+
# The platforms you wants to test on
5+
os:
6+
- linux
7+
8+
# git configs
9+
git:
10+
depth: 1
11+
12+
# codeclimate
13+
env:
14+
global:
15+
- CC_TEST_REPORTER_ID=5308141f77638e360604f49a1c0066d79a4870c26c9fb68523d790b36df5174b
16+
- GIT_COMMITTED_AT=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then git log -1 --pretty=format:%ct; else git log -1 --skip 1 --pretty=format:%ct; fi)
17+
18+
# Define the php versions against we want to test our code
19+
php:
20+
- 7.0
21+
- 7.1
22+
- 5.6
23+
24+
matrix:
25+
fast_finish: true
26+
27+
28+
# We don't want to run linux commands as super user
29+
sudo: false
30+
31+
# Get the codeclimate stuff
32+
before_script:
33+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
34+
- chmod +x ./cc-test-reporter
35+
- ./cc-test-reporter before-build
36+
37+
# Composer package installation
38+
install:
39+
# Install composer packages, will also trigger dump-autoload
40+
- travis_retry composer install --no-interaction
41+
42+
# Testing the app (see phpunit.xml), generating Code Coverage report
43+
script:
44+
- ./vendor/bin/phpunit --coverage-clover build/logs/clover.xml
45+
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
46+
47+
#after_failure:
48+
49+
# Tell Travis CI to monitor only 'master' branch
50+
branches:
51+
only: master
52+
53+
# Configure email notifications
54+
notifications:
55+
email:
56+
on_success: never
57+
on_failure: always
58+
59+
# You can delete cache using travis-ci web interface
60+
cache:
61+
directories:
62+
- vendor
63+
- $HOME/.cache/composer

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ numbers including floats. A few examples.
1212

1313
## Usage
1414

15+
### Manual Installation
16+
1517
**Clone this repository using git**
1618

1719
```bash
@@ -22,7 +24,7 @@ git clone git@github.com:swashata/php-number-to-word-india.git
2224

2325
```php
2426
<?php
25-
require_once 'ntwIndia/class-ntw-india.php';
27+
require_once 'src/NTWIndia.php';
2628
```
2729

2830
**Create an instance**
@@ -36,24 +38,24 @@ $ntw = new \ntwIndia\NTW_India();
3638

3739
```php
3840
<?php
39-
echo $ntw->num_to_word( 3104007200 );
41+
echo $ntw->numToWord( 3104007200 );
4042
// Will print Three Hundred Ten Crore Forty Lakh Seven Thousand Two Hundred
4143
```
4244

43-
If your number is always less than 100, then use `num_to_wd_small` method to
45+
If your number is always less than 100, then use `numToWordSmall` method to
4446
reduce memory usage.
4547

4648
```php
4749
<?php
48-
echo $ntw->num_to_wd_small( 99 );
50+
echo $ntw->numToWordSmall( 99 );
4951
// Will print Ninty Nine
5052
```
5153

5254
## Methods
5355

5456
Two methods are available
5557

56-
### `num_to_word`
58+
### `numToWord`
5759

5860
Converts any number to word including decimal values. Decimals are converted as
5961
`... And 986/1000`. You will mostly need to call this method.
@@ -67,10 +69,10 @@ Converts any number to word including decimal values. Decimals are converted as
6769
Returns `string` The word value of the number. All of the words have uppercased
6870
first letter.
6971

70-
### `num_to_wd_small`
72+
### `numToWordSmall`
7173

7274
Converts numbers smaller than 100 into words. If the number is greater than 99
73-
then it simply calls `num_to_word`.
75+
then it simply calls `numToWord`.
7476

7577
Use this when you know your number is lesser than 100 to reduce memory usage.
7678

@@ -93,7 +95,7 @@ To translate, kindly replace the public variables:
9395
* `$lakh`: Lakh word. Defaults *'Lakh'*.
9496
* `$crore`: Crore word. Defaults *'Crore'*.
9597
* `$and`: And word. Defaults *'And'*.
96-
* `$num_to_wd`: Contains mapping of numbers to words. From `0` to `20` and multiple
98+
* `$numToWord`: Contains mapping of numbers to words. From `0` to `20` and multiple
9799
of `10` upto `90`.
98100

99101
## Unit Test

composer.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
{
2+
"name": "ntwindia/ntwindia",
3+
"type": "library",
4+
"description": "Convert number to word in Indian English.",
5+
"keywords": ["number", "words", "number-to-words"],
6+
"homepage": "https://github.com/swashata/php-number-to-word-india",
7+
"license": "GPL-3.0",
28
"require": {
39
},
410
"require-dev": {
511
"phpunit/phpunit": "^6.0"
612
},
713
"autoload": {
814
"psr-4": {
9-
"ntwIndia\\": "src/"
15+
"NTWIndia\\": "src/"
1016
}
1117
}
1218
}

0 commit comments

Comments
 (0)