diff --git a/.github/lang/es-ES/README.md b/.github/lang/es-ES/README.md index 8fc57d3..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 @@ -62,56 +64,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 +176,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/.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 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. diff --git a/README.md b/README.md index fb1ff98..ef1d5e6 100644 --- a/README.md +++ b/README.md @@ -26,14 +26,16 @@ PHP library to get language name from code. - [TODO](#todo) - [Changelog](#changelog) - [Contribution](#contribution) -- [Sponsor](#Sponsor) +- [Sponsor](#sponsor) - [License](#license) --- ## 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 @@ -62,56 +64,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 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", 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 @@ - + 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; 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'));