From 9a352311a6ec97cda149d4f0c7dde48d03e14948 Mon Sep 17 00:00:00 2001 From: Josantonius Date: Thu, 9 Nov 2017 00:30:58 +0100 Subject: [PATCH] Updated to 1.1.5 version --- .gitattributes | 15 +- .gitignore | 13 +- .php_cs.dist | 120 +++++++++ .travis.yml | 9 +- CHANGELOG.md | 8 + CONDUCT.md | 75 +++++- README-ES.md | 29 ++- README.md | 31 ++- _config.yml | 1 - composer.json | 21 +- contributors.txt | 1 - phpcs.ruleset.xml => phpcs.xml | 6 +- phpmd.xml | 45 ++++ phpunit.xml.dist => phpunit.xml | 4 +- src/LanguageCode.php | 4 +- src/LanguageCodeCollection.php | 435 ++++++++++++++++---------------- tests/LanguageCodeTest.php | 53 ++-- 17 files changed, 575 insertions(+), 295 deletions(-) create mode 100644 .php_cs.dist delete mode 100644 _config.yml delete mode 100644 contributors.txt rename phpcs.ruleset.xml => phpcs.xml (53%) create mode 100644 phpmd.xml rename phpunit.xml.dist => phpunit.xml (95%) diff --git a/.gitattributes b/.gitattributes index 506cc19..2b2dd96 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,14 +1,11 @@ /tests export-ignore -.gitattributes export-ignore -.gitignore export-ignore -_config.yml export-ignore -.travis.yml export-ignore CHANGELOG.md export-ignore -phpunit.xml.dist export-ignore -CONDUCT.md export-ignore -contributors.txt export-ignore README.md export-ignore -phpcs.ruleset.xml export-ignore README-ES.md export-ignore +phpcs.xml export-ignore +phpunit.xml export-ignore +phpmd.xml export-ignore +.travis.yml export-ignore .editorconfig export-ignore -composer.lock export-ignore \ No newline at end of file +.gitattributes export-ignore +.gitignore export-ignore \ No newline at end of file diff --git a/.gitignore b/.gitignore index 8653580..b5216cd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,12 @@ -phpunit.xml +.git*/ +vendor/ +docs/*.pyc +docs/_build +build/artifacts/ composer.phar composer.lock composer-test.lock -build/artifacts/ -vendor/ -docs/_build -docs/*.pyc -.git*/ +phpcbf-fixed.diff .idea .DS_STORE +.php_cs.cache \ No newline at end of file diff --git a/.php_cs.dist b/.php_cs.dist new file mode 100644 index 0000000..6735b7d --- /dev/null +++ b/.php_cs.dist @@ -0,0 +1,120 @@ +setRiskyAllowed(true) + ->setRules(array( + '@PSR2' => true, + 'array_syntax' => ['syntax' => 'short'], + 'binary_operator_spaces' => ['align_equals' => false, 'align_double_arrow' => false], + 'blank_line_after_opening_tag' => true, + 'blank_line_after_namespace' => false, + 'blank_line_before_return' => true, + 'cast_spaces' => true, +// 'class_keyword_remove' => true, + 'combine_consecutive_unsets' => true, + 'concat_space' => ['spacing' => 'one'], + 'declare_equal_normalize' => true, + 'declare_strict_types' => false, + 'dir_constant' => true, + 'ereg_to_preg' => true, + 'function_typehint_space' => true, +// 'general_phpdoc_annotation_remove' => ['author', 'category', 'package', 'copyright', 'version'], + 'hash_to_slash_comment' => true, + 'heredoc_to_nowdoc' => true, + 'include' => true, + 'indentation_type' => true, +// 'is_null' => ['use_yoda_style' => false], + 'linebreak_after_opening_tag' => true, + 'lowercase_cast' => true, +// 'mb_str_functions' => true, + 'method_separation' => true, + 'modernize_types_casting' => true, + 'native_function_casing' => true, +// 'native_function_invocation' => true, + 'new_with_braces' => false, // + 'no_alias_functions' => true, + 'no_blank_lines_after_class_opening' => true, + 'no_blank_lines_after_phpdoc' => true, + 'no_blank_lines_before_namespace' => true, + 'no_empty_comment' => true, + 'no_empty_phpdoc' => true, + 'no_empty_statement' => true, + 'no_extra_consecutive_blank_lines' => ['break', 'continue', 'curly_brace_block', 'extra', 'parenthesis_brace_block', 'return', 'square_brace_block', 'throw', 'use', 'useTrait'], + 'no_leading_import_slash' => true, + 'no_leading_namespace_whitespace' => true, + 'no_mixed_echo_print' => ['use' => 'echo'], + 'no_multiline_whitespace_around_double_arrow' => true, + 'no_multiline_whitespace_before_semicolons' => true, + 'no_php4_constructor' => true, + 'no_short_bool_cast' => true, + 'no_short_echo_tag' => false, + 'no_singleline_whitespace_before_semicolons' => true, + 'no_spaces_around_offset' => true, + 'no_trailing_comma_in_list_call' => true, + 'no_trailing_comma_in_singleline_array' => true, + 'no_trailing_whitespace' => true, + 'no_trailing_whitespace_in_comment' => true, + 'no_unneeded_control_parentheses' => true, + 'no_unreachable_default_argument_value' => true, + 'no_unused_imports' => true, + 'no_useless_else' => true, + 'no_useless_return' => true, + 'no_whitespace_before_comma_in_array' => true, + 'no_whitespace_in_blank_line' => true, + 'normalize_index_brace' => true, + 'not_operator_with_space' => false, + 'not_operator_with_successor_space' => true, + 'object_operator_without_whitespace' => true, + 'ordered_class_elements' => true, + 'ordered_imports' => true, + 'php_unit_construct' => true, + 'php_unit_dedicate_assert' => true, + 'php_unit_fqcn_annotation' => true, + 'php_unit_strict' => true, +// 'phpdoc_add_missing_param_annotation' => true, + 'phpdoc_align' => true, + 'phpdoc_annotation_without_dot' => true, + 'phpdoc_indent' => true, + 'phpdoc_inline_tag' => true, + 'phpdoc_no_access' => true, + 'phpdoc_no_alias_tag' => ['property-read' => 'property', 'property-write' => 'property', 'type' => 'var'], + 'phpdoc_no_empty_return' => true, + 'phpdoc_no_package' => true, +// 'phpdoc_no_useless_inheritdoc' => true, + 'phpdoc_order' => true, + 'phpdoc_return_self_reference' => true, + 'phpdoc_scalar' => true, + 'phpdoc_separation' => false, + 'phpdoc_single_line_var_spacing' => true, +// 'phpdoc_summary' => true, + 'phpdoc_to_comment' => true, + 'phpdoc_trim' => true, + 'phpdoc_types' => true, + 'phpdoc_var_without_name' => true, + 'pow_to_exponentiation' => true, +// 'pre_increment' => true, + 'protected_to_private' => true, + 'psr0' => true, + 'psr4' => true, + 'random_api_migration' => true, + 'return_type_declaration' => ['space_before' => 'one'], + 'self_accessor' => true, + 'short_scalar_cast' => true, +// 'silenced_deprecation_error' => true, +// 'simplified_null_return' => true, + 'single_blank_line_before_namespace' => false, + 'single_quote' => true, + 'space_after_semicolon' => true, + 'standardize_not_equals' => true, +// 'strict_comparison' => true, + 'ternary_operator_spaces' => true, + 'strict_param' => true, + 'ternary_to_null_coalescing' => false, +// 'trailing_comma_in_multiline_array' => true, + 'trim_array_spaces' => true, + 'unary_operator_spaces' => true, + 'whitespace_after_comma_in_array' => true + )) + ->setFinder( + PhpCsFixer\Finder::create() + ->in(__DIR__) + )->setLineEnding("\n"); diff --git a/.travis.yml b/.travis.yml index 71306ca..8b88f00 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,10 @@ language: php sudo: false +cache: + directories: + - $HOME/.composer/cache + dist: trusty branches: @@ -18,7 +22,7 @@ php: - 7.2 - hhvm - nightly - + matrix: fast_finish: true include: @@ -37,7 +41,8 @@ script: - phpunit - | if [[ "$PHPCS" ]] ; then - phpcs --standard=phpcs.ruleset.xml $(find . -name '*.php') + phpcs --standard=phpcs.xml $(find . -name '*.php') + phpmd src,tests text ./phpmd.xml fi phpunit --coverage-clover=coverage.xml diff --git a/CHANGELOG.md b/CHANGELOG.md index c8271c0..02982c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # CHANGELOG +## 1.1.5 - 2017-11-08 + +* Implemented `PHP Mess Detector` to detect inconsistencies in code styles. + +* Implemented `PHP Code Beautifier and Fixer` to fixing errors automatically. + +* Implemented `PHP Coding Standards Fixer` to organize PHP code automatically according to PSR standards. + ## 1.1.4 - 2017-11-01 * Implemented `PSR-4 autoloader standard` from all library files. diff --git a/CONDUCT.md b/CONDUCT.md index 6ff94ca..30f74c5 100644 --- a/CONDUCT.md +++ b/CONDUCT.md @@ -1,22 +1,73 @@ -# Contributor Code of Conduct +# Contributor Covenant Code of Conduct -As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities. +## Our Pledge -We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality. +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +nationality, personal appearance, race, religion, or sexual identity and +orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members Examples of unacceptable behavior by participants include: -* The use of sexualized language or imagery -* Personal attacks -* Trolling or insulting/derogatory comments +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks * Public or private harassment -* Publishing other's private information, such as physical or electronic addresses, without explicit permission -* Other unethical or unprofessional conduct. +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at [INSERT EMAIL ADDRESS]. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. -Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team. +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. -This code of conduct applies both within project spaces and in public spaces when an individual is representing the project or its community in a direct capacity. Personal views, beliefs and values of individuals do not necessarily reflect those of the organisation or affiliated individuals and organisations. +## Attribution -Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers. +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html -This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/) +[homepage]: https://www.contributor-covenant.org diff --git a/README-ES.md b/README-ES.md index aafce4f..7c42e89 100644 --- a/README-ES.md +++ b/README-ES.md @@ -164,28 +164,39 @@ Ejecutar pruebas de estándares de código [PSR2](http://www.php-fig.org/psr/psr $ composer phpcs +Ejecutar pruebas con [PHP Mess Detector](https://phpmd.org/) para detectar inconsistencias en el estilo de codificación: + + $ composer phpmd + Ejecutar todas las pruebas anteriores: $ composer tests ## ☑ Tareas pendientes -- [x] Completar tests -- [x] Mejorar la documentación +- [ ] Añadir nueva funcionalidad +- [ ] Mejorar pruebas +- [ ] Mejorar documentación +- [ ] Refactorizar código ## Contribuir -1. Comprobar si hay incidencias abiertas o abrir una nueva para iniciar una discusión en torno a un fallo o función. -1. Bifurca la rama del repositorio en GitHub para iniciar la operación de ajuste. -1. Escribe una o más pruebas para la nueva característica o expón el error. -1. Haz cambios en el código para implementar la característica o reparar el fallo. -1. Envía pull request para fusionar los cambios y que sean publicados. +Si deseas colaborar, puedes echar un vistazo a la lista de +[issues](https://github.com/Josantonius/PHP-LanguageCode/issues) o [tareas pendientes](#-tareas-pendientes). + +**Pull requests** -Esto está pensado para proyectos grandes y de larga duración. +* [Fork and clone](https://help.github.com/articles/fork-a-repo). +* Ejecuta el comando `composer install` para instalar dependencias. + Esto también instalará las [dependencias de desarrollo](https://getcomposer.org/doc/03-cli.md#install). +* Ejecuta el comando `composer fix` para estandarizar el código. +* Ejecuta las [pruebas](#tests). +* Crea una nueva rama (**branch**), **commit**, **push** y envíame un + [pull request](https://help.github.com/articles/using-pull-requests). ## Repositorio -Los archivos de este repositorio se crearon y subieron automáticamente con [Reposgit Creator](https://github.com/Josantonius/BASH-Reposgit). +La estructura de archivos de este repositorio se creó con [PHP-Skeleton](https://github.com/Josantonius/PHP-Skeleton). ## Licencia diff --git a/README.md b/README.md index 9d6e7b7..15c04d4 100644 --- a/README.md +++ b/README.md @@ -115,7 +115,7 @@ Example of use for this library: ## Tests -To run [tests](tests) you just need [Composer](http://getcomposer.org/download/) and to execute the following: +To run [tests](tests) you just need [composer](http://getcomposer.org/download/) and to execute the following: $ git clone https://github.com/Josantonius/PHP-LanguageCode.git @@ -131,28 +131,39 @@ Run [PSR2](http://www.php-fig.org/psr/psr-2/) code standard tests with [PHPCS](h $ composer phpcs +Run [PHP Mess Detector](https://phpmd.org/) tests to detect inconsistencies in code style: + + $ composer phpmd + Run all previous tests: $ composer tests ## ☑ TODO -- [x] Create tests -- [x] Improve documentation +- [ ] Add new feature +- [ ] Improve tests +- [ ] Improve documentation +- [ ] Refactor code ## Contribute -1. Check for open issues or open a new issue to start a discussion around a bug or feature. -1. Fork the repository on GitHub to start making your changes. -1. Write one or more tests for the new feature or that expose the bug. -1. Make code changes to implement the feature or fix the bug. -1. Send a pull request to get your changes merged and published. +If you would like to help, please take a look at the list of +[issues](https://github.com/Josantonius/PHP-LanguageCode/issues) or the [To Do](#-todo) checklist. + +**Pull requests** -This is intended for large and long-lived objects. +* [Fork and clone](https://help.github.com/articles/fork-a-repo). +* Run the command `composer install` to install the dependencies. + This will also install the [dev dependencies](https://getcomposer.org/doc/03-cli.md#install). +* Run the command `composer fix` to excute code standard fixers. +* Run the [tests](#tests). +* Create a **branch**, **commit**, **push** and send me a + [pull request](https://help.github.com/articles/using-pull-requests). ## Repository -All files in this repository were created and uploaded automatically with [Reposgit Creator](https://github.com/Josantonius/BASH-Reposgit). +The file structure from this repository was created with [PHP-Skeleton](https://github.com/Josantonius/PHP-Skeleton). ## License diff --git a/_config.yml b/_config.yml deleted file mode 100644 index c419263..0000000 --- a/_config.yml +++ /dev/null @@ -1 +0,0 @@ -theme: jekyll-theme-cayman \ No newline at end of file diff --git a/composer.json b/composer.json index 668aaf9..9f6d9fc 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,5 @@ { "name": "josantonius/languagecode", - "version": "1.1.4", "type": "library", "description": "List of 217 language codes: ISO 639-1.", "keywords": [ @@ -32,8 +31,10 @@ "php": "^5.6 || ^7.0" }, "require-dev": { - "phpunit/phpunit": "5.7.*", - "squizlabs/php_codesniffer": "3.*" + "phpunit/phpunit": "^5.7 || ^6.0", + "squizlabs/php_codesniffer": "^3.0", + "friendsofphp/php-cs-fixer": "^2.3 || ^2.8", + "phpmd/phpmd": "^2.6" }, "autoload": { "psr-4": { @@ -52,7 +53,17 @@ }, "scripts": { "phpunit": "vendor/bin/phpunit --colors=always;", - "phpcs": "vendor/bin/phpcs --standard=phpcs.ruleset.xml $(find . -name '*.php');", - "tests": "clear && vendor/bin/phpcs --standard=phpcs.ruleset.xml $(find . -name '*.php') && vendor/bin/phpunit --colors=always;" + "phpcs": "vendor/bin/phpcs --standard=phpcs.xml $(find . -name '*.php');", + "phpmd": "vendor/bin/phpmd src,tests text ./phpmd.xml", + "fix": [ + "vendor/bin/php-cs-fixer fix -v", + "vendor/bin/phpcbf src,tests" + ], + "tests": [ + "clear", + "@phpmd", + "@phpcs", + "@phpunit" + ] } } diff --git a/contributors.txt b/contributors.txt deleted file mode 100644 index 37e53c5..0000000 --- a/contributors.txt +++ /dev/null @@ -1 +0,0 @@ -Josantonius diff --git a/phpcs.ruleset.xml b/phpcs.xml similarity index 53% rename from phpcs.ruleset.xml rename to phpcs.xml index ce35542..32363c5 100644 --- a/phpcs.ruleset.xml +++ b/phpcs.xml @@ -4,10 +4,14 @@ PHP Coding Standards + + + + node_modules vendor - + \ No newline at end of file diff --git a/phpmd.xml b/phpmd.xml new file mode 100644 index 0000000..8d48339 --- /dev/null +++ b/phpmd.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/phpunit.xml.dist b/phpunit.xml similarity index 95% rename from phpunit.xml.dist rename to phpunit.xml index 210966a..8a27461 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml @@ -6,7 +6,6 @@ convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" - strict="true" processIsolation="false" stopOnFailure="false" syntaxCheck="false" @@ -23,4 +22,5 @@ src - \ No newline at end of file + + diff --git a/src/LanguageCode.php b/src/LanguageCode.php index 5ad81ca..92b6fc3 100644 --- a/src/LanguageCode.php +++ b/src/LanguageCode.php @@ -8,7 +8,6 @@ * @link https://github.com/Josantonius/PHP-LanguageCode * @since 1.0.0 */ - namespace Josantonius\LanguageCode; /** @@ -18,7 +17,6 @@ */ class LanguageCode { - /** * Get all language codes as array. * @@ -56,6 +54,6 @@ public static function getLanguageFromCode($languageCode) */ public static function getCodeFromLanguage($languageName) { - return array_search($languageName, LanguageCodeCollection::all()); + return array_search($languageName, LanguageCodeCollection::all(), true); } } diff --git a/src/LanguageCodeCollection.php b/src/LanguageCodeCollection.php index 470d823..419ffa3 100644 --- a/src/LanguageCodeCollection.php +++ b/src/LanguageCodeCollection.php @@ -8,7 +8,6 @@ * @link https://github.com/Josantonius/PHP-LanguageCode * @since 1.1.4 */ - namespace Josantonius\LanguageCode; /** @@ -28,223 +27,223 @@ class LanguageCodeCollection * @var array */ protected static $data = [ - "aa" => "Afar", - "ab" => "Abkhazian", - "af" => "Afrikaans", - "am" => "Amharic", - "ar" => "Arabic", - "ar-ae" => "Arabic (U.A.E.)", - "ar-bh" => "Arabic (Bahrain)", - "ar-dz" => "Arabic (Algeria)", - "ar-eg" => "Arabic (Egypt)", - "ar-iq" => "Arabic (Iraq)", - "ar-jo" => "Arabic (Jordan)", - "ar-kw" => "Arabic (Kuwait)", - "ar-lb" => "Arabic (Lebanon)", - "ar-ly" => "Arabic (libya)", - "ar-ma" => "Arabic (Morocco)", - "ar-om" => "Arabic (Oman)", - "ar-qa" => "Arabic (Qatar)", - "ar-sa" => "Arabic (Saudi Arabia)", - "ar-sy" => "Arabic (Syria)", - "ar-tn" => "Arabic (Tunisia)", - "ar-ye" => "Arabic (Yemen)", - "as" => "Assamese", - "ay" => "Aymara", - "az" => "Azeri", - "ba" => "Bashkir", - "be" => "Belarusian", - "bg" => "Bulgarian", - "bh" => "Bihari", - "bi" => "Bislama", - "bn" => "Bengali", - "bo" => "Tibetan", - "br" => "Breton", - "ca" => "Catalan", - "co" => "Corsican", - "cs" => "Czech", - "cy" => "Welsh", - "da" => "Danish", - "de" => "German", - "de-at" => "German (Austria)", - "de-ch" => "German (Switzerland)", - "de-li" => "German (Liechtenstein)", - "de-lu" => "German (Luxembourg)", - "div" => "Divehi", - "dz" => "Bhutani", - "el" => "Greek", - "en" => "English", - "en-au" => "English (Australia)", - "en-bz" => "English (Belize)", - "en-ca" => "English (Canada)", - "en-gb" => "English (United Kingdom)", - "en-ie" => "English (Ireland)", - "en-jm" => "English (Jamaica)", - "en-nz" => "English (New Zealand)", - "en-ph" => "English (Philippines)", - "en-tt" => "English (Trinidad)", - "en-us" => "English (United States)", - "en-za" => "English (South Africa)", - "en-zw" => "English (Zimbabwe)", - "eo" => "Esperanto", - "es" => "Spanish", - "es-ar" => "Spanish (Argentina)", - "es-bo" => "Spanish (Bolivia)", - "es-cl" => "Spanish (Chile)", - "es-co" => "Spanish (Colombia)", - "es-cr" => "Spanish (Costa Rica)", - "es-do" => "Spanish (Dominican Republic)", - "es-ec" => "Spanish (Ecuador)", - "es-es" => "Spanish (España)", - "es-gt" => "Spanish (Guatemala)", - "es-hn" => "Spanish (Honduras)", - "es-mx" => "Spanish (Mexico)", - "es-ni" => "Spanish (Nicaragua)", - "es-pa" => "Spanish (Panama)", - "es-pe" => "Spanish (Peru)", - "es-pr" => "Spanish (Puerto Rico)", - "es-py" => "Spanish (Paraguay)", - "es-sv" => "Spanish (El Salvador)", - "es-us" => "Spanish (United States)", - "es-uy" => "Spanish (Uruguay)", - "es-ve" => "Spanish (Venezuela)", - "et" => "Estonian", - "eu" => "Basque", - "fa" => "Farsi", - "fi" => "Finnish", - "fj" => "Fiji", - "fo" => "Faeroese", - "fr" => "French", - "fr-be" => "French (Belgium)", - "fr-ca" => "French (Canada)", - "fr-ch" => "French (Switzerland)", - "fr-lu" => "French (Luxembourg)", - "fr-mc" => "French (Monaco)", - "fy" => "Frisian", - "ga" => "Irish", - "gd" => "Gaelic", - "gl" => "Galician", - "gn" => "Guarani", - "gu" => "Gujarati", - "ha" => "Hausa", - "he" => "Hebrew", - "hi" => "Hindi", - "hr" => "Croatian", - "hu" => "Hungarian", - "hy" => "Armenian", - "ia" => "Interlingua", - "id" => "Indonesian", - "ie" => "Interlingue", - "ik" => "Inupiak", - "in" => "Indonesian", - "is" => "Icelandic", - "it" => "Italian", - "it-ch" => "Italian (Switzerland)", - "iw" => "Hebrew", - "ja" => "Japanese", - "ji" => "Yiddish", - "jw" => "Javanese", - "ka" => "Georgian", - "kk" => "Kazakh", - "kl" => "Greenlandic", - "km" => "Cambodian", - "kn" => "Kannada", - "ko" => "Korean", - "kok" => "Konkani", - "ks" => "Kashmiri", - "ku" => "Kurdish", - "ky" => "Kirghiz", - "kz" => "Kyrgyz", - "la" => "Latin", - "ln" => "Lingala", - "lo" => "Laothian", - "ls" => "Slovenian", - "lt" => "Lithuanian", - "lv" => "Latvian", - "mg" => "Malagasy", - "mi" => "Maori", - "mk" => "FYRO Macedonian", - "ml" => "Malayalam", - "mn" => "Mongolian", - "mo" => "Moldavian", - "mr" => "Marathi", - "ms" => "Malay", - "mt" => "Maltese", - "my" => "Burmese", - "na" => "Nauru", - "nb-no" => "Norwegian (Bokmal)", - "ne" => "Nepali (India)", - "nl" => "Dutch", - "nl-be" => "Dutch (Belgium)", - "nn-no" => "Norwegian", - "no" => "Norwegian (Bokmal)", - "oc" => "Occitan", - "om" => "(Afan)/Oromoor/Oriya", - "or" => "Oriya", - "pa" => "Punjabi", - "pl" => "Polish", - "ps" => "Pashto/Pushto", - "pt" => "Portuguese", - "pt-br" => "Portuguese (Brazil)", - "qu" => "Quechua", - "rm" => "Rhaeto-Romanic", - "rn" => "Kirundi", - "ro" => "Romanian", - "ro-md" => "Romanian (Moldova)", - "ru" => "Russian", - "ru-md" => "Russian (Moldova)", - "rw" => "Kinyarwanda", - "sa" => "Sanskrit", - "sb" => "Sorbian", - "sd" => "Sindhi", - "sg" => "Sangro", - "sh" => "Serbo-Croatian", - "si" => "Singhalese", - "sk" => "Slovak", - "sl" => "Slovenian", - "sm" => "Samoan", - "sn" => "Shona", - "so" => "Somali", - "sq" => "Albanian", - "sr" => "Serbian", - "ss" => "Siswati", - "st" => "Sesotho", - "su" => "Sundanese", - "sv" => "Swedish", - "sv-fi" => "Swedish (Finland)", - "sw" => "Swahili", - "sx" => "Sutu", - "syr" => "Syriac", - "ta" => "Tamil", - "te" => "Telugu", - "tg" => "Tajik", - "th" => "Thai", - "ti" => "Tigrinya", - "tk" => "Turkmen", - "tl" => "Tagalog", - "tn" => "Tswana", - "to" => "Tonga", - "tr" => "Turkish", - "ts" => "Tsonga", - "tt" => "Tatar", - "tw" => "Twi", - "uk" => "Ukrainian", - "ur" => "Urdu", - "us" => "English", - "uz" => "Uzbek", - "vi" => "Vietnamese", - "vo" => "Volapuk", - "wo" => "Wolof", - "xh" => "Xhosa", - "yi" => "Yiddish", - "yo" => "Yoruba", - "zh" => "Chinese", - "zh-cn" => "Chinese (China)", - "zh-hk" => "Chinese (Hong Kong SAR)", - "zh-mo" => "Chinese (Macau SAR)", - "zh-sg" => "Chinese (Singapore)", - "zh-tw" => "Chinese (Taiwan)", - "zu" => "Zulu" + 'aa' => 'Afar', + 'ab' => 'Abkhazian', + 'af' => 'Afrikaans', + 'am' => 'Amharic', + 'ar' => 'Arabic', + 'ar-ae' => 'Arabic (U.A.E.)', + 'ar-bh' => 'Arabic (Bahrain)', + 'ar-dz' => 'Arabic (Algeria)', + 'ar-eg' => 'Arabic (Egypt)', + 'ar-iq' => 'Arabic (Iraq)', + 'ar-jo' => 'Arabic (Jordan)', + 'ar-kw' => 'Arabic (Kuwait)', + 'ar-lb' => 'Arabic (Lebanon)', + 'ar-ly' => 'Arabic (libya)', + 'ar-ma' => 'Arabic (Morocco)', + 'ar-om' => 'Arabic (Oman)', + 'ar-qa' => 'Arabic (Qatar)', + 'ar-sa' => 'Arabic (Saudi Arabia)', + 'ar-sy' => 'Arabic (Syria)', + 'ar-tn' => 'Arabic (Tunisia)', + 'ar-ye' => 'Arabic (Yemen)', + 'as' => 'Assamese', + 'ay' => 'Aymara', + 'az' => 'Azeri', + 'ba' => 'Bashkir', + 'be' => 'Belarusian', + 'bg' => 'Bulgarian', + 'bh' => 'Bihari', + 'bi' => 'Bislama', + 'bn' => 'Bengali', + 'bo' => 'Tibetan', + 'br' => 'Breton', + 'ca' => 'Catalan', + 'co' => 'Corsican', + 'cs' => 'Czech', + 'cy' => 'Welsh', + 'da' => 'Danish', + 'de' => 'German', + 'de-at' => 'German (Austria)', + 'de-ch' => 'German (Switzerland)', + 'de-li' => 'German (Liechtenstein)', + 'de-lu' => 'German (Luxembourg)', + 'div' => 'Divehi', + 'dz' => 'Bhutani', + 'el' => 'Greek', + 'en' => 'English', + 'en-au' => 'English (Australia)', + 'en-bz' => 'English (Belize)', + 'en-ca' => 'English (Canada)', + 'en-gb' => 'English (United Kingdom)', + 'en-ie' => 'English (Ireland)', + 'en-jm' => 'English (Jamaica)', + 'en-nz' => 'English (New Zealand)', + 'en-ph' => 'English (Philippines)', + 'en-tt' => 'English (Trinidad)', + 'en-us' => 'English (United States)', + 'en-za' => 'English (South Africa)', + 'en-zw' => 'English (Zimbabwe)', + 'eo' => 'Esperanto', + 'es' => 'Spanish', + 'es-ar' => 'Spanish (Argentina)', + 'es-bo' => 'Spanish (Bolivia)', + 'es-cl' => 'Spanish (Chile)', + 'es-co' => 'Spanish (Colombia)', + 'es-cr' => 'Spanish (Costa Rica)', + 'es-do' => 'Spanish (Dominican Republic)', + 'es-ec' => 'Spanish (Ecuador)', + 'es-es' => 'Spanish (España)', + 'es-gt' => 'Spanish (Guatemala)', + 'es-hn' => 'Spanish (Honduras)', + 'es-mx' => 'Spanish (Mexico)', + 'es-ni' => 'Spanish (Nicaragua)', + 'es-pa' => 'Spanish (Panama)', + 'es-pe' => 'Spanish (Peru)', + 'es-pr' => 'Spanish (Puerto Rico)', + 'es-py' => 'Spanish (Paraguay)', + 'es-sv' => 'Spanish (El Salvador)', + 'es-us' => 'Spanish (United States)', + 'es-uy' => 'Spanish (Uruguay)', + 'es-ve' => 'Spanish (Venezuela)', + 'et' => 'Estonian', + 'eu' => 'Basque', + 'fa' => 'Farsi', + 'fi' => 'Finnish', + 'fj' => 'Fiji', + 'fo' => 'Faeroese', + 'fr' => 'French', + 'fr-be' => 'French (Belgium)', + 'fr-ca' => 'French (Canada)', + 'fr-ch' => 'French (Switzerland)', + 'fr-lu' => 'French (Luxembourg)', + 'fr-mc' => 'French (Monaco)', + 'fy' => 'Frisian', + 'ga' => 'Irish', + 'gd' => 'Gaelic', + 'gl' => 'Galician', + 'gn' => 'Guarani', + 'gu' => 'Gujarati', + 'ha' => 'Hausa', + 'he' => 'Hebrew', + 'hi' => 'Hindi', + 'hr' => 'Croatian', + 'hu' => 'Hungarian', + 'hy' => 'Armenian', + 'ia' => 'Interlingua', + 'id' => 'Indonesian', + 'ie' => 'Interlingue', + 'ik' => 'Inupiak', + 'in' => 'Indonesian', + 'is' => 'Icelandic', + 'it' => 'Italian', + 'it-ch' => 'Italian (Switzerland)', + 'iw' => 'Hebrew', + 'ja' => 'Japanese', + 'ji' => 'Yiddish', + 'jw' => 'Javanese', + 'ka' => 'Georgian', + 'kk' => 'Kazakh', + 'kl' => 'Greenlandic', + 'km' => 'Cambodian', + 'kn' => 'Kannada', + 'ko' => 'Korean', + 'kok' => 'Konkani', + 'ks' => 'Kashmiri', + 'ku' => 'Kurdish', + 'ky' => 'Kirghiz', + 'kz' => 'Kyrgyz', + 'la' => 'Latin', + 'ln' => 'Lingala', + 'lo' => 'Laothian', + 'ls' => 'Slovenian', + 'lt' => 'Lithuanian', + 'lv' => 'Latvian', + 'mg' => 'Malagasy', + 'mi' => 'Maori', + 'mk' => 'FYRO Macedonian', + 'ml' => 'Malayalam', + 'mn' => 'Mongolian', + 'mo' => 'Moldavian', + 'mr' => 'Marathi', + 'ms' => 'Malay', + 'mt' => 'Maltese', + 'my' => 'Burmese', + 'na' => 'Nauru', + 'nb-no' => 'Norwegian (Bokmal)', + 'ne' => 'Nepali (India)', + 'nl' => 'Dutch', + 'nl-be' => 'Dutch (Belgium)', + 'nn-no' => 'Norwegian', + 'no' => 'Norwegian (Bokmal)', + 'oc' => 'Occitan', + 'om' => '(Afan)/Oromoor/Oriya', + 'or' => 'Oriya', + 'pa' => 'Punjabi', + 'pl' => 'Polish', + 'ps' => 'Pashto/Pushto', + 'pt' => 'Portuguese', + 'pt-br' => 'Portuguese (Brazil)', + 'qu' => 'Quechua', + 'rm' => 'Rhaeto-Romanic', + 'rn' => 'Kirundi', + 'ro' => 'Romanian', + 'ro-md' => 'Romanian (Moldova)', + 'ru' => 'Russian', + 'ru-md' => 'Russian (Moldova)', + 'rw' => 'Kinyarwanda', + 'sa' => 'Sanskrit', + 'sb' => 'Sorbian', + 'sd' => 'Sindhi', + 'sg' => 'Sangro', + 'sh' => 'Serbo-Croatian', + 'si' => 'Singhalese', + 'sk' => 'Slovak', + 'sl' => 'Slovenian', + 'sm' => 'Samoan', + 'sn' => 'Shona', + 'so' => 'Somali', + 'sq' => 'Albanian', + 'sr' => 'Serbian', + 'ss' => 'Siswati', + 'st' => 'Sesotho', + 'su' => 'Sundanese', + 'sv' => 'Swedish', + 'sv-fi' => 'Swedish (Finland)', + 'sw' => 'Swahili', + 'sx' => 'Sutu', + 'syr' => 'Syriac', + 'ta' => 'Tamil', + 'te' => 'Telugu', + 'tg' => 'Tajik', + 'th' => 'Thai', + 'ti' => 'Tigrinya', + 'tk' => 'Turkmen', + 'tl' => 'Tagalog', + 'tn' => 'Tswana', + 'to' => 'Tonga', + 'tr' => 'Turkish', + 'ts' => 'Tsonga', + 'tt' => 'Tatar', + 'tw' => 'Twi', + 'uk' => 'Ukrainian', + 'ur' => 'Urdu', + 'us' => 'English', + 'uz' => 'Uzbek', + 'vi' => 'Vietnamese', + 'vo' => 'Volapuk', + 'wo' => 'Wolof', + 'xh' => 'Xhosa', + 'yi' => 'Yiddish', + 'yo' => 'Yoruba', + 'zh' => 'Chinese', + 'zh-cn' => 'Chinese (China)', + 'zh-hk' => 'Chinese (Hong Kong SAR)', + 'zh-mo' => 'Chinese (Macau SAR)', + 'zh-sg' => 'Chinese (Singapore)', + 'zh-tw' => 'Chinese (Taiwan)', + 'zu' => 'Zulu' ]; /** diff --git a/tests/LanguageCodeTest.php b/tests/LanguageCodeTest.php index 7262ed6..7c0d6c6 100644 --- a/tests/LanguageCodeTest.php +++ b/tests/LanguageCodeTest.php @@ -8,7 +8,6 @@ * @link https://github.com/Josantonius/PHP-LanguageCode * @since 1.1.3 */ - namespace Josantonius\LanguageCode; use PHPUnit\Framework\TestCase; @@ -20,18 +19,48 @@ */ class LanguageCodeTest extends TestCase { + /** + * LanguageCode instance. + * + * @since 1.1.5 + * + * @var object + */ + protected $LanguageCode; + + /** + * Set up. + * + * @since 1.1.5 + */ + public function setUp() + { + parent::setUp(); + + $this->LanguageCode = new LanguageCode; + } + + /** + * Check if it is an instance of LanguageCode. + * + * @since 1.1.5 + */ + public function testIsInstanceOfLanguageCode() + { + $actual = $this->LanguageCode; + $this->assertInstanceOf('Josantonius\LanguageCode\LanguageCode', $actual); + } + /** * Get language name from language code. * * @since 1.1.3 - * - * @return void */ public function testGetLanguageFromCode() { $this->assertContains( 'Spanish', - LanguageCode::getLanguageFromCode('es') + $this->LanguageCode->getLanguageFromCode('es') ); } @@ -39,13 +68,11 @@ public function testGetLanguageFromCode() * Getting a language name wrong. * * @since 1.1.3 - * - * @return void */ public function testGetLanguageFromCodeUndefined() { $this->assertFalse( - LanguageCode::getLanguageFromCode('abcd') + $this->LanguageCode->getLanguageFromCode('abcd') ); } @@ -53,14 +80,12 @@ public function testGetLanguageFromCodeUndefined() * Get language code from language name * * @since 1.1.3 - * - * @return void */ public function testGetCodeFromLanguage() { $this->assertContains( 'es', - LanguageCode::getCodeFromLanguage('Spanish') + $this->LanguageCode->getCodeFromLanguage('Spanish') ); } @@ -68,13 +93,11 @@ public function testGetCodeFromLanguage() * Getting a language code wrong. * * @since 1.1.3 - * - * @return void */ public function testGetCodeFromLanguageUndefined() { $this->assertFalse( - LanguageCode::getCodeFromLanguage('abcd') + $this->LanguageCode->getCodeFromLanguage('abcd') ); } @@ -82,14 +105,12 @@ public function testGetCodeFromLanguageUndefined() * Get all language codes as array. * * @since 1.1.3 - * - * @return void */ public function testGetAll() { $this->assertInternalType( 'array', - LanguageCode::get() + $this->LanguageCode->get() ); } }