-
Notifications
You must be signed in to change notification settings - Fork 11
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
0 parents
commit 23ab1d9
Showing
20 changed files
with
912 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
; This file is for unifying the coding style for different editors and IDEs. | ||
; More information at http://editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_size = 4 | ||
indent_style = space | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
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,10 @@ | ||
# Path-based git attributes | ||
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html | ||
|
||
# Ignore all test and documentation with "export-ignore". | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
/.travis.yml export-ignore | ||
/phpunit.xml.dist export-ignore | ||
/.scrutinizer.yml export-ignore | ||
/tests export-ignore |
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,5 @@ | ||
build | ||
composer.lock | ||
docs | ||
vendor | ||
.idea |
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,18 @@ | ||
filter: | ||
excluded_paths: [tests/*] | ||
|
||
checks: | ||
php: | ||
remove_extra_empty_lines: true | ||
remove_php_closing_tag: true | ||
remove_trailing_whitespace: true | ||
fix_use_statements: | ||
remove_unused: true | ||
preserve_multiple: false | ||
preserve_blanklines: true | ||
order_alphabetically: true | ||
fix_php_opening_tag: true | ||
fix_linefeed: true | ||
fix_line_ending: true | ||
fix_identation_4spaces: true | ||
fix_doc_comments: true |
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 @@ | ||
preset: laravel |
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,22 @@ | ||
language: php | ||
|
||
php: | ||
- 5.6 | ||
- 7.0 | ||
- 7.1 | ||
- 7.2 | ||
|
||
env: | ||
matrix: | ||
- COMPOSER_FLAGS="--prefer-lowest" | ||
- COMPOSER_FLAGS="" | ||
|
||
before_script: | ||
- travis_retry composer self-update | ||
- travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-source | ||
|
||
script: | ||
- phpunit --coverage-text --coverage-clover=coverage.clover | ||
|
||
after_script: | ||
- php vendor/bin/ocular code-coverage:upload --format=php-clover coverage.clover |
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,7 @@ | ||
# Changelog | ||
|
||
All notable changes to `laravel-arabic-numbers-middleware` will be documented in this file. | ||
|
||
## 1.0.0 - 2017-10-04 | ||
|
||
- Initial release |
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,32 @@ | ||
# Contributing | ||
|
||
Contributions are **welcome** and will be fully **credited**. | ||
|
||
We accept contributions via Pull Requests on [Github](https://github.com/yemenifree/laravel-arabic-numbers-middleware). | ||
|
||
|
||
## Pull Requests | ||
|
||
- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - Check the code style with ``$ composer check-style`` and fix it with ``$ composer fix-style``. | ||
|
||
- **Add tests!** - Your patch won't be accepted if it doesn't have tests. | ||
|
||
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. | ||
|
||
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option. | ||
|
||
- **Create feature branches** - Don't ask us to pull from your master branch. | ||
|
||
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. | ||
|
||
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. | ||
|
||
|
||
## Running Tests | ||
|
||
``` bash | ||
$ phpunit | ||
``` | ||
|
||
|
||
**Happy coding**! |
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 @@ | ||
# The MIT License (MIT) | ||
|
||
Copyright (c) 2017 Salah Alkhwlani <[email protected]> | ||
|
||
> Permission is hereby granted, free of charge, to any person obtaining a copy | ||
> of this software and associated documentation files (the "Software"), to deal | ||
> in the Software without restriction, including without limitation the rights | ||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
> copies of the Software, and to permit persons to whom the Software is | ||
> furnished to do so, subject to the following conditions: | ||
> | ||
> The above copyright notice and this permission notice shall be included in | ||
> all copies or substantial portions of the Software. | ||
> | ||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
> THE SOFTWARE. |
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,177 @@ | ||
# Transform between (Arabic-english)/(eastern-Indian) numbers middleware for laravel | ||
|
||
[![Latest Version on Packagist][ico-version]][link-packagist] | ||
[![Software License][ico-license]](LICENSE.md) | ||
[![Build Status][ico-travis]][link-travis] | ||
[![Coverage Status][ico-scrutinizer]][link-scrutinizer] | ||
[![Quality Score][ico-code-quality]][link-code-quality] | ||
[![Total Downloads][ico-downloads]][link-downloads] | ||
|
||
> A tiny package to transforms [arabic](https://en.wikipedia.org/wiki/Arabic_numerals)/[eastern*](https://en.wikipedia.org/wiki/Eastern_Arabic_numerals) to [eastern*](https://en.wikipedia.org/wiki/Eastern_Arabic_numerals)/[arabic](https://en.wikipedia.org/wiki/Arabic_numerals) numbers for i.e `١٢٣٤٥٦٧٨` to `12345678` before validations to avoid invalid integers error when pass `eastern` numbers by (ios/mac) users | ||
* These numbers are known as أرقام هندية ("Indian numbers") in Arabic. They are sometimes also called "Indic numerals" in English. However, that is sometimes discouraged as it can lead to confusion with Indian numerals | ||
|
||
|
||
## Install | ||
|
||
Via Composer | ||
|
||
``` bash | ||
$ composer require yemenifree/laravel-arabic-numbers-middleware | ||
``` | ||
|
||
## Usage | ||
|
||
If you do not run Laravel 5.5 (or higher), then add the service provider in `config/app.php`: | ||
|
||
```php | ||
Yemenifree\LaravelArabicNumbersMiddleware\ServiceProvider::class, | ||
``` | ||
|
||
If you do run the package on Laravel 5.5+, [package auto-discovery](https://medium.com/@taylorotwell/package-auto-discovery-in-laravel-5-5-ea9e3ab20518) takes care of the magic of adding the service provider. | ||
|
||
That's it! by default package automatic transform all `eastern` numbers to `arabic` for all requests | ||
|
||
Package includes two middleware | ||
|
||
- "eastern-to-arabic" to transform numbers from eastern to arabic (i.e `١٢٣` to `123`) | ||
- "arabic-to-eastern" to transform numbers from arabic to eastern (i.e `123` to `١٢٣`) | ||
|
||
You can use middleware for custom router for example | ||
|
||
```php | ||
Route::any('/login', ['middleware' => 'eastern-to-arabic', function () { | ||
// your code | ||
}]); | ||
``` | ||
|
||
you can ignore fields from transform by pass fields name as parameters to middleware for example | ||
|
||
```php | ||
// ignore transform pass field | ||
Route::any('/login', ['middleware' => 'arabic-to-eastern:pass', function () { | ||
// your code | ||
}]); | ||
|
||
// you can also ignore multi fields | ||
Route::any('/login', ['middleware' => 'arabic-to-eastern:pass,test', function () { | ||
// your code | ||
}]); | ||
``` | ||
|
||
> inline ignore fields not work if `auto_register_middleware` enable and middleware you want use inside `auto_middleware` option , instead use can set ignore fields in config file `arabic-numbers-middleware.php` | ||
## Optional | ||
|
||
if you want customizes configuration you can publish the configuration | ||
|
||
```bash | ||
$ php artisan vendor:publish --provider="Yemenifree\LaravelArabicNumbersMiddleware\ServiceProvider" | ||
``` | ||
|
||
This is the content of the published config file `arabic-numbers-middleware.php`: | ||
|
||
```php | ||
return [ | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| enable auto register middleware for all requests | ||
|-------------------------------------------------------------------------- | ||
| | ||
| if you want auto register for custom middleware group | ||
| 'auto_register_middleware' => ['web'], //for web group only | ||
| 'auto_register_middleware' => true, // all groups | ||
| 'auto_register_middleware' => false, // none | ||
*/ | ||
'auto_register_middleware' => true, | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| list of middleware they will resisted for all requests automatic by package | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Supported Middleware: "arabic-to-eastern", "eastern-to-arabic" | ||
*/ | ||
'auto_middleware' => [ | ||
Yemenifree\LaravelArabicNumbersMiddleware\Middleware\TransformHindiToArabicNumbers::class | ||
], | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| except fields ( POST | GET ) to ignore transform from all middleware | ||
|-------------------------------------------------------------------------- | ||
| | ||
| all none string will be ignore, you can ignore fields by name (key) of POST or GET | ||
| | ||
*/ | ||
'except_from_all' => [ | ||
// 'login' | ||
], | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| except fields ( POST | GET ) to ignore transform from eastern to arabic | ||
|-------------------------------------------------------------------------- | ||
| | ||
| all none string will be ignore, you can ignore fields by name (key) of POST or GET | ||
| | ||
*/ | ||
'except_from_eastern_to_arabic' => [ | ||
// 'mobile' | ||
], | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| except fields ( POST | GET ) to ignore transform from arabic to eastern | ||
|-------------------------------------------------------------------------- | ||
| | ||
| all none string will be ignore, you can ignore fields by name (key) of POST or GET | ||
| | ||
*/ | ||
'except_from_arabic_to_eastern' => [ | ||
// 'mobile' | ||
] | ||
]; | ||
``` | ||
|
||
## Change log | ||
|
||
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. | ||
|
||
## Testing | ||
|
||
``` bash | ||
$ composer test | ||
``` | ||
|
||
## Contributing | ||
|
||
Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md) for details. | ||
|
||
## Security | ||
|
||
If you discover any security related issues, please email [email protected] instead of using the issue tracker. | ||
|
||
## Credits | ||
|
||
- [Salah Alkhwlani][link-author] | ||
- [All Contributors][link-contributors] | ||
|
||
## License | ||
|
||
The MIT License (MIT). Please see [License File](LICENSE.md) for more information. | ||
|
||
[ico-version]: https://img.shields.io/packagist/v/yemenifree/laravel-arabic-numbers-middleware.svg?style=flat-square | ||
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square | ||
[ico-travis]: https://img.shields.io/travis/yemenifree/laravel-arabic-numbers-middleware/master.svg?style=flat-square | ||
[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/yemenifree/laravel-arabic-numbers-middleware.svg?style=flat-square | ||
[ico-code-quality]: https://img.shields.io/scrutinizer/g/yemenifree/laravel-arabic-numbers-middleware.svg?style=flat-square | ||
[ico-downloads]: https://img.shields.io/packagist/dt/yemenifree/laravel-arabic-numbers-middleware.svg?style=flat-square | ||
|
||
[link-packagist]: https://packagist.org/packages/yemenifree/laravel-arabic-numbers-middleware | ||
[link-travis]: https://travis-ci.org/yemenifree/laravel-arabic-numbers-middleware | ||
[link-scrutinizer]: https://scrutinizer-ci.com/g/yemenifree/laravel-arabic-numbers-middleware/code-structure | ||
[link-code-quality]: https://scrutinizer-ci.com/g/yemenifree/laravel-arabic-numbers-middleware | ||
[link-downloads]: https://packagist.org/packages/yemenifree/laravel-arabic-numbers-middleware | ||
[link-author]: https://github.com/yemenifree | ||
[link-contributors]: ../../contributors |
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,64 @@ | ||
{ | ||
"name": "yemenifree/laravel-arabic-numbers-middleware", | ||
"type": "library", | ||
"description": "auto transforms arabic/eastern to eastern/arabic numbers for i.e ١٢٣٤٥٦٧٨ to 12345678", | ||
"keywords": [ | ||
"yemenifree", | ||
"laravel", | ||
"middleware", | ||
"laravel-arabic-numbers-middleware", | ||
"eastern numbers", | ||
"arabic numbers", | ||
"english numbers", | ||
"Indian numbers", | ||
"arabic", | ||
"numbers" | ||
], | ||
"homepage": "https://github.com/yemenifree/laravel-arabic-numbers-middleware", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Salah ALkhwlani", | ||
"email": "[email protected]", | ||
"homepage": "http://twitter.com/salahAlkhwlani", | ||
"role": "Developer" | ||
} | ||
], | ||
"require": { | ||
"illuminate/support": "~5.1", | ||
"php" : "~5.6|~7.0" | ||
}, | ||
"require-dev": { | ||
"orchestra/testbench": "^3.5", | ||
"phpunit/phpunit": ">=5.4.3", | ||
"squizlabs/php_codesniffer": "^2.3" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Yemenifree\\LaravelArabicNumbersMiddleware\\": "src" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Yemenifree\\LaravelArabicNumbersMiddleware\\Test\\": "tests" | ||
} | ||
}, | ||
"scripts": { | ||
"test": "phpunit", | ||
"check-style": "phpcs -p --standard=PSR2 --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 src tests", | ||
"fix-style": "phpcbf -p --standard=PSR2 --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 src tests" | ||
}, | ||
"extra": { | ||
"branch-alias": { | ||
"dev-master": "1.0-dev" | ||
}, | ||
"laravel": { | ||
"providers": [ | ||
"Yemenifree\\LaravelArabicNumbersMiddleware\\ServiceProvider" | ||
] | ||
} | ||
}, | ||
"config": { | ||
"sort-packages": true | ||
} | ||
} |
Oops, something went wrong.