-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Konstantin Kutsevalov
committed
Nov 15, 2017
1 parent
6701362
commit ab6e4ee
Showing
5 changed files
with
75 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,33 @@ | ||
# sum2str | ||
# Sum 2 String | ||
Перевод суммы из числа в строку. | ||
|
||
Примеры: | ||
|
||
```php | ||
Sum::toStr(2546.34); // => "две тысячи пятьсот сорок шесть рублей 34 коп." | ||
use adamasantares\Sum2Str; | ||
|
||
Sum:toStr(1500210.50); // => "один миллион пятьсот тысяч двести десять рублей 50 коп." | ||
Sum2Str::toStr(2546.34); // => "две тысячи пятьсот сорок шесть рублей 34 коп." | ||
|
||
Sum:toStr(150, false); // => "сто пятьдесят" | ||
Sum2Str::toStr(1500210.50); // => "один миллион пятьсот тысяч двести десять рублей 50 коп." | ||
|
||
Sum2Str::toStr(150, false); // => "сто пятьдесят" | ||
``` | ||
|
||
Если не нужны дополнительные файлы и классы, можно просто скопировать метод и использовать как самостоятельную функцию или встроить его в свой класс, в котом будет использоваться. | ||
|
||
Замечания и исправления приветствуются, но не вознаграждаются ;) | ||
|
||
|
||
## Composer | ||
|
||
``` | ||
composer require adamasantares/sum2str "0.1.1" | ||
``` | ||
|
||
or | ||
|
||
``` | ||
"require": { | ||
"adamasantares/sum2str": "0.1.1" | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "adamasantares/sum2str", | ||
"description": "Перевод суммы из числа в строку", | ||
"keywords": ["sum to string", "russian language only"], | ||
"homepage": "https://github.com/adamasantares/sum2str#readme", | ||
"type": "library", | ||
"minimum-stability": "dev", | ||
"prefer-stable" : true, | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Konstantin Kutsevalov", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"require": { | ||
"php": ">=7.0.0" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"adamasantares\\sum2str\\": "" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
require_once(__DIR__ . '/run.php'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
/** | ||
* Примитивный тест | ||
*/ | ||
|
||
require_once __DIR__ . '/../Sum2Str.php'; | ||
|
||
use adamasantares\Sum2Str; | ||
|
||
echo "=== Test of 'sum2str' ===\n"; | ||
|
||
$t1 = Sum2Str::toStr(2546.34); | ||
echo $t1 . ($t1 == 'две тысячи пятьсот сорок шесть рублей 34 коп.' ? " - OK\n" : " - FAIL\n"); | ||
|
||
$t2 = Sum2Str::toStr(1500210.50); | ||
echo $t2 . ($t2 == 'один миллион пятьсот тысяч двести десять рублей 50 коп.' ? " - OK\n" : " - FAIL\n"); | ||
|
||
$t3 = Sum2Str::toStr(150, false); // => "сто пятьдесят" | ||
echo $t3 . ($t3 == 'сто пятьдесят' ? " - OK\n" : " - FAIL\n"); | ||
|
||
echo "=== Done ===\n"; |