From 01cfbb8daa421d1968e339c24a01ae32a766bed5 Mon Sep 17 00:00:00 2001 From: Josantonius Date: Sat, 27 Aug 2022 23:36:43 +0200 Subject: [PATCH 1/9] build: disable rule The CamelCaseMethodName rule was disabled to avoid alerts on function names in tests. Closes #3 --- phpmd.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpmd.xml b/phpmd.xml index 8d1a39d..781c921 100644 --- a/phpmd.xml +++ b/phpmd.xml @@ -34,7 +34,7 @@ - + From af7036a6228bf7a7c2b7fe54ebf2189e22ec5bdf Mon Sep 17 00:00:00 2001 From: Josantonius Date: Sat, 27 Aug 2022 23:37:48 +0200 Subject: [PATCH 2/9] docs: add functions to document methods Functions were added to document the methods and avoid confusion. Closes #3 --- .github/lang/es-ES/README.md | 28 +++++++++++++++------------- README.md | 20 ++++++++++---------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/.github/lang/es-ES/README.md b/.github/lang/es-ES/README.md index 657f361..28aac8b 100644 --- a/.github/lang/es-ES/README.md +++ b/.github/lang/es-ES/README.md @@ -17,13 +17,13 @@ Biblioteca de PHP para obtener mensajes y definiciones de códigos de estado HTT - [Requisitos](#requisitos) - [Instalación](#instalación) -- [Available Classes](#available-classes) +- [Clases disponibles](#clases-disponibles) - [Clase HttpStatusCode](#clase-httpstatuscode) - [Excepciones utilizadas](#excepciones-utilizadas) - [Uso](#uso) - [Listado en formato JSON](#listado-en-formato-json) - [Tests](#tests) -- [Tareas pendientes](#-tareas-pendientes) +- [Tareas pendientes](#tareas-pendientes) - [Registro de Cambios](#registro-de-cambios) - [Contribuir](#contribuir) - [Patrocinar](#patrocinar) @@ -62,9 +62,7 @@ git clone https://github.com/josantonius/http-status-code.git ### Clase HttpStatusCode -```php -use Josantonius\HttpStatusCode\HttpStatusCode; -``` +`Josantonius\HttpStatusCode\HttpStatusCode` Crear una nueva instancia que defina el idioma: @@ -77,37 +75,37 @@ Crear una nueva instancia que defina el idioma: * * @throws UnsupportedLanguageException if language is not supported. */ -$httpStatusCode = new HttpStatusCode(string $language = 'en'); +public function __construct(string $language = 'en'); ``` Obtiene el mensaje de un código de estado HTTP: ```php -$httpStatusCode->getMessage(int $code): string|null +public function getMessage(int $code): string|null; ``` Obtiene los mensajes de todos los códigos de estado HTTP: ```php -$httpStatusCode->getMessages(): array +public function getMessages(): array; ``` Obtiene la definición de un código de estado HTTP: ```php -$httpStatusCode->getDefinition(int $code): string|null +public function getDefinition(int $code): string|null; ``` Obtiene las definiciones de todos los códigos de estado HTTP: ```php -$httpStatusCode->getDefinitions(): array +public function getDefinitions(): array; ``` Obtiene mensajes y definiciones de todos los códigos de estado HTTP: ```php -$httpStatusCode->getAll(): array +public function getAll(): array; ``` ## Excepciones utilizadas @@ -123,10 +121,14 @@ Ejemplo de uso para esta biblioteca: ### Crear una nueva instancia que defina el idioma ```php +use Josantonius\HttpStatusCode\HttpStatusCode; + $httpStatusCode = new HttpStatusCode(); // Obtiene los mensajes en inglés. ``` ```php +use Josantonius\HttpStatusCode\HttpStatusCode; + $httpStatusCode = new HttpStatusCode('es'); // Obtiene los mensajes en español. ``` @@ -235,9 +237,9 @@ $httpStatusCode->getAll(); ] ``` -## List in Json format +## Listado en formato JSON -[Go to the resource](https://gist.github.com/Josantonius/b455e315bc7f790d14b136d61d9ae469). +[Ir al recurso](https://gist.github.com/Josantonius/b455e315bc7f790d14b136d61d9ae469). ## Tests diff --git a/README.md b/README.md index 6794efd..b74ad45 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ PHP library to get HTTP status code messages and definitions. - [TODO](#todo) - [Changelog](#changelog) - [Contribution](#contribution) -- [Sponsor](#Sponsor) +- [Sponsor](#sponsor) - [License](#license) --- @@ -62,9 +62,7 @@ git clone https://github.com/josantonius/http-status-code.git ### HttpStatusCode Class -```php -use Josantonius\HttpStatusCode\HttpStatusCode; -``` +`Josantonius\HttpStatusCode\HttpStatusCode` Create a new instance defining the language: @@ -77,37 +75,37 @@ Create a new instance defining the language: * * @throws UnsupportedLanguageException if language is not supported. */ -$httpStatusCode = new HttpStatusCode(string $language = 'en'); +public function __construct(string $language = 'en'); ``` Gets message of an HTTP status code: ```php -$httpStatusCode->getMessage(int $code): string|null +public function getMessage(int $code): string|null; ``` Gets the messages of all HTTP status codes: ```php -$httpStatusCode->getMessages(): array +public function getMessages(): array; ``` Gets definition of an HTTP status code: ```php -$httpStatusCode->getDefinition(int $code): string|null +public function getDefinition(int $code): string|null; ``` Gets the definitions of all HTTP status codes: ```php -$httpStatusCode->getDefinitions(): array +public function getDefinitions(): array; ``` Gets messages and definitions of all HTTP status codes: ```php -$httpStatusCode->getAll(): array +public function getAll(): array; ``` ## Exceptions Used @@ -129,6 +127,8 @@ $httpStatusCode = new HttpStatusCode(); // Gets the messages in English. ``` ```php +use Josantonius\HttpStatusCode\HttpStatusCode; + $httpStatusCode = new HttpStatusCode('es'); // Gets the messages in Spanish. ``` From e261015c060536d922dfe073f4454750174d0420 Mon Sep 17 00:00:00 2001 From: Josantonius Date: Sat, 27 Aug 2022 23:38:27 +0200 Subject: [PATCH 3/9] refactor: fix comment alignment The alignment of the asterisks in the comments has been fixed. Closes #3 --- src/Exceptions/UnsupportedLanguageException.php | 14 +++++++------- src/HttpStatusCode.php | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Exceptions/UnsupportedLanguageException.php b/src/Exceptions/UnsupportedLanguageException.php index 88421f9..221354a 100644 --- a/src/Exceptions/UnsupportedLanguageException.php +++ b/src/Exceptions/UnsupportedLanguageException.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-http-status-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\HttpStatusCode\Exceptions; diff --git a/src/HttpStatusCode.php b/src/HttpStatusCode.php index e2aaa4d..d5bd28a 100644 --- a/src/HttpStatusCode.php +++ b/src/HttpStatusCode.php @@ -3,13 +3,13 @@ declare(strict_types=1); /* -* This file is part of https://github.com/josantonius/php-http-status-code repository. -* -* (c) Josantonius -* -* 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-http-status-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\HttpStatusCode; From f9a42719b512d38092d5a2f024854e87a18a49ec Mon Sep 17 00:00:00 2001 From: Josantonius Date: Sat, 27 Aug 2022 23:38:42 +0200 Subject: [PATCH 4/9] 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 #3 --- tests/HttpStatusCodeTest.php | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/tests/HttpStatusCodeTest.php b/tests/HttpStatusCodeTest.php index de402b1..3a9b0e0 100644 --- a/tests/HttpStatusCodeTest.php +++ b/tests/HttpStatusCodeTest.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-http-status-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\HttpStatusCode\Tests; @@ -29,14 +31,14 @@ public function setUp(): void $this->httpStatusCodeEs = new HttpStatusCode('es'); } - public function testShouldFailIfUnsupportedLanguageIsUsed() + public function test_should_fail_if_unsupported_language_is_used() { $this->expectException(UnsupportedLanguageException::class); new HttpStatusCode('fr'); } - public function testShouldGetMessage() + public function test_should_get_message() { $this->assertEquals( 'Request Time-out', @@ -49,7 +51,7 @@ public function testShouldGetMessage() ); } - public function testShouldGetMessages() + public function test_should_get_messages() { $messages = $this->httpStatusCodeEn->getMessages(); @@ -57,7 +59,7 @@ public function testShouldGetMessages() $this->assertArrayHasKey(408, $messages); } - public function testShouldGetDefinition() + public function test_should_get_definition() { $this->assertStringContainsString( 'The server timed out waiting for the request.', @@ -70,7 +72,7 @@ public function testShouldGetDefinition() ); } - public function testShouldGetDefinitions() + public function test_should_get_definitions() { $definitions = $this->httpStatusCodeEn->getDefinitions(); @@ -78,7 +80,7 @@ public function testShouldGetDefinitions() $this->assertArrayHasKey(408, $definitions); } - public function testShouldGetAll() + public function test_should_get_all() { $all = $this->httpStatusCodeEn->getAll(); From a1d22f2c0248601153f15757d25dd61dbbb49682 Mon Sep 17 00:00:00 2001 From: Josantonius Date: Thu, 29 Sep 2022 18:47:05 +0200 Subject: [PATCH 5/9] docs: improve documentation Closes #4 --- .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 28aac8b..8ca145b 100644 --- a/.github/lang/es-ES/README.md +++ b/.github/lang/es-ES/README.md @@ -33,7 +33,9 @@ Biblioteca de PHP para obtener mensajes y definiciones de códigos de estado HTT ## Requisitos -Esta biblioteca es compatible con las versiones de PHP: 8.0 | 8.1. +- Sistema operativo: Linux | Windows. + +- Versiones de PHP: 8.1 | 8.2. ## Instalación diff --git a/README.md b/README.md index b74ad45..92fba35 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,9 @@ PHP library to get HTTP status code messages and definitions. ## Requirements -Esta biblioteca es compatible con las versiones de PHP: 8.0 | 8.1. +- Operating System: Linux | Windows. + +- PHP versions: 8.1 | 8.2. ## Installation From 2a7b7a53d09444a878bd8f35555b3f7676568af1 Mon Sep 17 00:00:00 2001 From: Josantonius Date: Thu, 29 Sep 2022 18:47:28 +0200 Subject: [PATCH 6/9] build: add scripts and normalize Closes #4 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3361b2b..afd4083 100644 --- a/composer.json +++ b/composer.json @@ -56,7 +56,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 aaf9145d386e89f31b978df2061ff2ef23ad321f Mon Sep 17 00:00:00 2001 From: Josantonius Date: Thu, 29 Sep 2022 18:47:50 +0200 Subject: [PATCH 7/9] ci: add windows and php 8.2 Closes #4 --- .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 f0d1f293cda6fadc1db6bd60ba65b553084c2c67 Mon Sep 17 00:00:00 2001 From: Josantonius Date: Thu, 29 Sep 2022 18:48:15 +0200 Subject: [PATCH 8/9] docs: release notes for the v2.0.3 version Closes #4 --- CHANGELOG.md | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c34ecd..9ae3d94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,14 +1,28 @@ # CHANGELOG -## [v2.0.3](https://github.com/josantonius/php-json/releases/tag/v2.0.3) (2022-08-11) +## [v2.0.4](https://github.com/josantonius/php-http-status-code/releases/tag/v2.0.4) (2022-09-29) + +* 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.3](https://github.com/josantonius/php-http-status-code/releases/tag/v2.0.3) (2022-08-11) * Improved documentation. -## [v2.0.2](https://github.com/josantonius/php-json/releases/tag/v2.0.2) (2022-08-04) +## [v2.0.2](https://github.com/josantonius/php-http-status-code/releases/tag/v2.0.2) (2022-08-04) * Fix Packagist URL in `README.md` files -## [v2.0.1](https://github.com/josantonius/php-json/releases/tag/v2.0.1) (2022-07-31) +## [v2.0.1](https://github.com/josantonius/php-http-status-code/releases/tag/v2.0.1) (2022-07-31) * The links in the `CHANGELOG.md` file have been fixed. @@ -20,7 +34,7 @@ **Full Changelog**: -## [v2.0.0](https://github.com/josantonius/php-json/releases/tag/v2.0.0) (2022-07-31) +## [v2.0.0](https://github.com/josantonius/php-http-status-code/releases/tag/v2.0.0) (2022-07-31) > Version 1.x is considered as deprecated and unsupported. > In this version (2.x) the library was completely restructured. @@ -64,13 +78,13 @@ * Deleted `README-ES.MD` file. * Deleted `.php_cs.dist` file. -## [1.1.6](https://github.com/josantonius/php-json/releases/tag/1.1.6) (2018-01-06) +## [1.1.6](https://github.com/josantonius/php-http-status-code/releases/tag/1.1.6) (2018-01-06) * The tests were fixed. * Changes in documentation. -## [1.1.5](https://github.com/josantonius/php-json/releases/tag/1.1.5) (2017-11-08) +## [1.1.5](https://github.com/josantonius/php-http-status-code/releases/tag/1.1.5) (2017-11-08) * Implemented `PHP Mess Detector` to detect inconsistencies in code styles. @@ -78,7 +92,7 @@ * Implemented `PHP Coding Standards Fixer` to organize PHP code automatically according to PSR standards. -## [1.1.4](https://github.com/josantonius/php-json/releases/tag/1.1.4) (2017-10-30) +## [1.1.4](https://github.com/josantonius/php-http-status-code/releases/tag/1.1.4) (2017-10-30) * Implemented `PSR-4 autoloader standard` from all library files. @@ -108,7 +122,7 @@ * Deleted `Josantonius\HTTPStatusCode\HTTPStatusCode::load()` method. -## [1.1.3](https://github.com/josantonius/php-json/releases/tag/1.1.3) (2017-09-13) +## [1.1.3](https://github.com/josantonius/php-http-status-code/releases/tag/1.1.3) (2017-09-13) * Unit tests supported by `PHPUnit` were added. @@ -138,21 +152,21 @@ * Added `Josantonius\HTTPStatusCode\Test\HTTPStatusCodeTest::test()` method. -## [1.1.2](https://github.com/josantonius/php-json/releases/tag/1.1.2) (2017-07-16) +## [1.1.2](https://github.com/josantonius/php-http-status-code/releases/tag/1.1.2) (2017-07-16) * Deleted `Josantonius\HTTPStatusCode\Exception\HTTPStatusCodeException` class. * Deleted `Josantonius\HTTPStatusCode\Exception\Exceptions` abstract class. * Deleted `Josantonius\HTTPStatusCode\Exception\HTTPStatusCodeException->__construct()` method. -## [1.1.1](https://github.com/josantonius/php-json/releases/tag/1.1.1) (2017-03-18) +## [1.1.1](https://github.com/josantonius/php-http-status-code/releases/tag/1.1.1) (2017-03-18) * Some files were excluded from download and comments and readme files were updated. -## [1.1.0](https://github.com/josantonius/php-json/releases/tag/1.1.0) (2017-01-30) +## [1.1.0](https://github.com/josantonius/php-http-status-code/releases/tag/1.1.0) (2017-01-30) * Compatible with PHP 5.6 or higher. -## [1.0.0](https://github.com/josantonius/php-json/releases/tag/1.0.0) (2016-12-19) +## [1.0.0](https://github.com/josantonius/php-http-status-code/releases/tag/1.0.0) (2016-12-19) * Compatible only with PHP 7.0 or higher. In the next versions, the library will be modified to make it compatible with PHP 5.6 or higher. From e73e8b012ff8b1f0235940b9ab56ceeba8467e2d Mon Sep 17 00:00:00 2001 From: Josantonius Date: Thu, 29 Sep 2022 18:50:22 +0200 Subject: [PATCH 9/9] docs: improve documentation Closes #4 --- .github/lang/es-ES/README.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/lang/es-ES/README.md b/.github/lang/es-ES/README.md index 8ca145b..477bcfd 100644 --- a/.github/lang/es-ES/README.md +++ b/.github/lang/es-ES/README.md @@ -35,7 +35,7 @@ Biblioteca de PHP para obtener mensajes y definiciones de códigos de estado HTT - Sistema operativo: Linux | Windows. -- Versiones de PHP: 8.1 | 8.2. +- Versiones de PHP: 8.0 | 8.1 | 8.2. ## Instalación diff --git a/README.md b/README.md index 92fba35..4daba9e 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ PHP library to get HTTP status code messages and definitions. - Operating System: Linux | Windows. -- PHP versions: 8.1 | 8.2. +- PHP versions: 8.0 | 8.1 | 8.2. ## Installation