diff --git a/.github/lang/es-ES/README.md b/.github/lang/es-ES/README.md index 657f361..477bcfd 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) @@ -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.0 | 8.1 | 8.2. ## Instalación @@ -62,9 +64,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 +77,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 +123,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 +239,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/.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 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. diff --git a/README.md b/README.md index 6794efd..4daba9e 100644 --- a/README.md +++ b/README.md @@ -26,14 +26,16 @@ PHP library to get HTTP status code messages and definitions. - [TODO](#todo) - [Changelog](#changelog) - [Contribution](#contribution) -- [Sponsor](#Sponsor) +- [Sponsor](#sponsor) - [License](#license) --- ## Requirements -Esta biblioteca es compatible con las versiones de PHP: 8.0 | 8.1. +- Operating System: Linux | Windows. + +- PHP versions: 8.0 | 8.1 | 8.2. ## Installation @@ -62,9 +64,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 +77,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 +129,8 @@ $httpStatusCode = new HttpStatusCode(); // Gets the messages in English. ``` ```php +use Josantonius\HttpStatusCode\HttpStatusCode; + $httpStatusCode = new HttpStatusCode('es'); // Gets the messages in Spanish. ``` 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", diff --git a/phpmd.xml b/phpmd.xml index 8d1a39d..781c921 100644 --- a/phpmd.xml +++ b/phpmd.xml @@ -34,7 +34,7 @@ - + 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; 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();