From 960308c33beeea2ad5055b63d1336aef4a33eb56 Mon Sep 17 00:00:00 2001 From: Josantonius Date: Sun, 28 Aug 2022 00:40:47 +0200 Subject: [PATCH 1/8] build: disable rule The CamelCaseMethodName rule was disabled to avoid alerts on function names in tests. Closes #2 --- phpmd.xml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/phpmd.xml b/phpmd.xml index 6459aa5..3208928 100644 --- a/phpmd.xml +++ b/phpmd.xml @@ -1,10 +1,8 @@ Coding standard. @@ -34,7 +32,7 @@ - + From 20dd3ce43aee98a5afa22ed378ff476c6e19a1d5 Mon Sep 17 00:00:00 2001 From: Josantonius Date: Sun, 28 Aug 2022 00:41:22 +0200 Subject: [PATCH 2/8] docs: add functions to document methods Functions were added to document the methods and avoid confusion. Closes #2 --- .github/lang/es-ES/README.md | 30 ++++++++++++------------------ README.md | 28 +++++++++------------------- 2 files changed, 21 insertions(+), 37 deletions(-) diff --git a/.github/lang/es-ES/README.md b/.github/lang/es-ES/README.md index 8fc57d3..0bc51f3 100644 --- a/.github/lang/es-ES/README.md +++ b/.github/lang/es-ES/README.md @@ -62,56 +62,46 @@ clone https://github.com/josantonius/php-language-code.git ### Clase LanguageCode -```php -use Josantonius\LanguageCode\LanguageCode; -``` - -Crear objeto: - -```php -$languageCode = new LanguageCode(); -``` +`Josantonius\LanguageCode\LanguageCode` Obtener array con todos los códigos de idioma: ```php -$languageCode->all(): array +public static function all(): array ``` Obtener código de idioma desde el nombre del idioma: ```php -$languageCode->getCode(string $languageName): string|null +public static function getCode(string $languageName): string|null ``` Obtener el nombre del idioma desde código de idioma: ```php -$languageCode->getName(string $languageCode): string|null +public static function getName(string $languageCode): string|null ``` ### Clase LanguageCodeCollection -```php -use Josantonius\LanguageCode\LanguageCodeCollection; -``` +`Josantonius\LanguageCode\LanguageCodeCollection` Obtener array con todos los códigos de idioma: ```php -LanguageCodeCollection::all(): array +public static function all(): array ``` Obtener código de idioma desde el nombre del idioma: ```php -LanguageCodeCollection::getCode(string $languageName): string|null +public static function getCode(string $languageName): string|null ``` Obtener el nombre del idioma desde código de idioma: ```php -LanguageCodeCollection::getName(string $languageCode): string|null +public static function getName(string $languageCode): string|null ``` ## Uso @@ -184,6 +174,10 @@ use Josantonius\LanguageCode\LanguageCodeCollection; LanguageCodeCollection::getName('de'); // German ``` +## Listado en formato JSON + +[Ir al recurso](https://gist.github.com/josantonius/b455e315bc7f790d14b136d61d9ae469). + ## Tests Para ejecutar las [pruebas](tests) necesitarás [Composer](http://getcomposer.org/download/) diff --git a/README.md b/README.md index fb1ff98..f92e2ad 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ PHP library to get language name from code. - [TODO](#todo) - [Changelog](#changelog) - [Contribution](#contribution) -- [Sponsor](#Sponsor) +- [Sponsor](#sponsor) - [License](#license) --- @@ -62,56 +62,46 @@ clone https://github.com/josantonius/php-language-code.git ### LanguageCode Class -```php -use Josantonius\LanguageCode\LanguageCode; -``` - -Create object: - -```php -$languageCode = new LanguageCode(); -``` +`Josantonius\LanguageCode\LanguageCode` Get all language codes as array: ```php -$languageCode->all(): array +public static function all(): array; ``` Get language code from language name: ```php -$languageCode->getCode(string $languageName): string|null +public static function getCode(string $languageName): string|null; ``` Get language name from language code: ```php -$languageCode->getName(string $languageCode): string|null +public static function getName(string $languageCode): string|null; ``` ### LanguageCodeCollection Class -```php -use Josantonius\LanguageCode\LanguageCodeCollection; -``` +`Josantonius\LanguageCode\LanguageCodeCollection` Get all language codes as array: ```php -LanguageCodeCollection::all(): array +public static function all(): array ``` Get language code from language name: ```php -LanguageCodeCollection::getCode(string $languageName): string|null +public static function getCode(string $languageName): string|null ``` Get language name from language code: ```php -LanguageCodeCollection::getName(string $languageCode): string|null +public static function getName(string $languageCode): string|null ``` ## Usage From 3b85454079d5dfbd4bb1cdca61e2b51f860647fa Mon Sep 17 00:00:00 2001 From: Josantonius Date: Sun, 28 Aug 2022 00:41:36 +0200 Subject: [PATCH 3/8] refactor: fix comment alignment The alignment of the asterisks in the comments has been fixed. Closes #2 --- src/LanguageCode.php | 14 +++++++------- src/LanguageCodeCollection.php | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/LanguageCode.php b/src/LanguageCode.php index 06171fc..0ab1e75 100644 --- a/src/LanguageCode.php +++ b/src/LanguageCode.php @@ -1,13 +1,13 @@ -* -* For the full copyright and license information, please view the LICENSE -* file that was distributed with this source code. -*/ + * This file is part of https://github.com/josantonius/php-language-code repository. + * + * (c) Josantonius + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ namespace Josantonius\LanguageCode; diff --git a/src/LanguageCodeCollection.php b/src/LanguageCodeCollection.php index 11e3aa0..331e5a3 100644 --- a/src/LanguageCodeCollection.php +++ b/src/LanguageCodeCollection.php @@ -1,13 +1,13 @@ -* -* For the full copyright and license information, please view the LICENSE -* file that was distributed with this source code. -*/ + * This file is part of https://github.com/josantonius/php-language-code repository. + * + * (c) Josantonius + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ namespace Josantonius\LanguageCode; From ff5233407899acdd60ab4691c501009d26f9f553 Mon Sep 17 00:00:00 2001 From: Josantonius Date: Sun, 28 Aug 2022 00:41:45 +0200 Subject: [PATCH 4/8] refactor: change notation type in methods The notation type in the test function names has been changed from camel to snake case for readability. Closes #2 --- tests/LanguageCodeTest.php | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/tests/LanguageCodeTest.php b/tests/LanguageCodeTest.php index b59f432..80f97f9 100644 --- a/tests/LanguageCodeTest.php +++ b/tests/LanguageCodeTest.php @@ -1,13 +1,15 @@ -* -* For the full copyright and license information, please view the LICENSE -* file that was distributed with this source code. -*/ + * This file is part of https://github.com/josantonius/php-language-code repository. + * + * (c) Josantonius + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + * @phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps + */ namespace Josantonius\LanguageCode\Tests; @@ -27,35 +29,35 @@ public function setUp(): void $this->languageCode = new LanguageCode(); } - public function testShouldGetAllLanguageCodes(): void + public function test_should_get_all_language_codes(): void { $this->assertNotEmpty($this->languageCode->all()); $this->assertNotEmpty($this->collection->all()); } - public function testShouldGetLanguageCodeFromLanguageName(): void + public function test_should_get_language_code_from_language_name(): void { $this->assertSame('es', $this->languageCode->getCode('Spanish')); $this->assertSame('es', $this->collection->getCode('Spanish')); } - public function testShouldReturnNullWithUnknownLanguageName(): void + public function test_should_return_null_with_unknown_language_name(): void { $this->assertNull($this->languageCode->getCode('foo')); $this->assertNull($this->collection->getCode('foo')); } - public function testShouldGetLanguageNameFromLanguageCode(): void + public function test_should_get_language_name_from_language_code(): void { $this->assertSame('Spanish', $this->languageCode->getName('es')); $this->assertSame('Spanish', $this->collection->getName('es')); } - public function testShouldReturnNullWithUnknownLanguageCode(): void + public function test_should_return_null_with_unknown_language_code(): void { $this->assertNull($this->languageCode->getName('bar')); From 16309591bf3ec9144efe7895c01d1e5cf6384c72 Mon Sep 17 00:00:00 2001 From: Josantonius Date: Thu, 29 Sep 2022 19:35:10 +0200 Subject: [PATCH 5/8] docs: improve documentation Closes #3 --- .github/lang/es-ES/README.md | 4 +++- README.md | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/lang/es-ES/README.md b/.github/lang/es-ES/README.md index 0bc51f3..3bad95d 100644 --- a/.github/lang/es-ES/README.md +++ b/.github/lang/es-ES/README.md @@ -33,7 +33,9 @@ Librería PHP para obtener el nombre del lenguaje a partir del código. ## Requisitos -Esta biblioteca es compatible con las versiones de PHP: 8.0 | 8.1. +Sistema operativo: Linux | Windows. + +Versiones de PHP: 8.0 | 8.1 | 8.2. ## Instalación diff --git a/README.md b/README.md index f92e2ad..ef1d5e6 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,9 @@ PHP library to get language name from code. ## Requirements -This library is compatible with the PHP versions: 8.0 | 8.1. +Operating System: Linux | Windows. + +PHP versions: 8.0 | 8.1 | 8.2. ## Installation From ea094255ded48e50884620d9e40961864fdcb76d Mon Sep 17 00:00:00 2001 From: Josantonius Date: Thu, 29 Sep 2022 19:35:31 +0200 Subject: [PATCH 6/8] build: add scripts and normalize Closes #3 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5aecfc5..b9f8e8b 100644 --- a/composer.json +++ b/composer.json @@ -57,7 +57,7 @@ "htmlCoverage": "vendor/bin/phpunit --coverage-html coverage", "phpcs": "vendor/bin/phpcs --standard=phpcs.xml $(find . -name '*.php');", "phpmd": "vendor/bin/phpmd src,tests text ./phpmd.xml", - "phpunit": "vendor/bin/phpunit --colors=always;", + "phpunit": "vendor/bin/phpunit", "tests": [ "clear", "@phpmd", From b91d5396fa658e3f6c0122ebb4a99653b7fa7855 Mon Sep 17 00:00:00 2001 From: Josantonius Date: Thu, 29 Sep 2022 19:35:43 +0200 Subject: [PATCH 7/8] ci: add windows and php 8.2 Closes #3 --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 93e8597..9641eae 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,10 +43,11 @@ jobs: name: 'PHPUnit (PHP ${{ matrix.php }} - ${{ matrix.system }})' strategy: matrix: - system: ['ubuntu-latest'] + system: ['ubuntu-latest', 'windows-latest'] php: - '8.0' - '8.1' + - '8.2' steps: - name: Checkout Code uses: actions/checkout@v3 From de179c6598b5ce42c8f4f8683383220ec22e0049 Mon Sep 17 00:00:00 2001 From: Josantonius Date: Thu, 29 Sep 2022 19:36:03 +0200 Subject: [PATCH 8/8] docs: release notes for the v2.0.2 version Closes #3 --- CHANGELOG.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dce359c..7c5522a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # CHANGELOG +## [v2.0.2](https://github.com/josantonius/php-language-code/releases/tag/v2.0.2) (2022-XX-XX) + +* The notation type in the test function names has been changed from camel to snake case for readability. + +* Functions were added to document the methods and avoid confusion. + +* Disabled the ´CamelCaseMethodName´ rule in ´phpmd.xml´ to avoid warnings about function names in tests. + +* The alignment of the asterisks in the comments has been fixed. + +* Tests for Windows have been added. + +* Tests for PHP 8.2 have been added. + ## [v2.0.1](https://github.com/josantonius/php-language-code/releases/tag/v2.0.1) (2022-08-11) * Improved documentation.