Skip to content

Commit 9a32cd2

Browse files
authored
Merge pull request #3 from josantonius/release/v2.0.2
Release/v2.0.2
2 parents dcb5e5a + de179c6 commit 9a32cd2

File tree

9 files changed

+76
-73
lines changed

9 files changed

+76
-73
lines changed

.github/lang/es-ES/README.md

+15-19
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ Librería PHP para obtener el nombre del lenguaje a partir del código.
3333

3434
## Requisitos
3535

36-
Esta biblioteca es compatible con las versiones de PHP: 8.0 | 8.1.
36+
Sistema operativo: Linux | Windows.
37+
38+
Versiones de PHP: 8.0 | 8.1 | 8.2.
3739

3840
## Instalación
3941

@@ -62,56 +64,46 @@ clone https://github.com/josantonius/php-language-code.git
6264

6365
### Clase LanguageCode
6466

65-
```php
66-
use Josantonius\LanguageCode\LanguageCode;
67-
```
68-
69-
Crear objeto:
70-
71-
```php
72-
$languageCode = new LanguageCode();
73-
```
67+
`Josantonius\LanguageCode\LanguageCode`
7468

7569
Obtener array con todos los códigos de idioma:
7670

7771
```php
78-
$languageCode->all(): array
72+
public static function all(): array
7973
```
8074

8175
Obtener código de idioma desde el nombre del idioma:
8276

8377
```php
84-
$languageCode->getCode(string $languageName): string|null
78+
public static function getCode(string $languageName): string|null
8579
```
8680

8781
Obtener el nombre del idioma desde código de idioma:
8882

8983
```php
90-
$languageCode->getName(string $languageCode): string|null
84+
public static function getName(string $languageCode): string|null
9185
```
9286

9387
### Clase LanguageCodeCollection
9488

95-
```php
96-
use Josantonius\LanguageCode\LanguageCodeCollection;
97-
```
89+
`Josantonius\LanguageCode\LanguageCodeCollection`
9890

9991
Obtener array con todos los códigos de idioma:
10092

10193
```php
102-
LanguageCodeCollection::all(): array
94+
public static function all(): array
10395
```
10496

10597
Obtener código de idioma desde el nombre del idioma:
10698

10799
```php
108-
LanguageCodeCollection::getCode(string $languageName): string|null
100+
public static function getCode(string $languageName): string|null
109101
```
110102

111103
Obtener el nombre del idioma desde código de idioma:
112104

113105
```php
114-
LanguageCodeCollection::getName(string $languageCode): string|null
106+
public static function getName(string $languageCode): string|null
115107
```
116108

117109
## Uso
@@ -184,6 +176,10 @@ use Josantonius\LanguageCode\LanguageCodeCollection;
184176
LanguageCodeCollection::getName('de'); // German
185177
```
186178

179+
## Listado en formato JSON
180+
181+
[Ir al recurso](https://gist.github.com/josantonius/b455e315bc7f790d14b136d61d9ae469).
182+
187183
## Tests
188184

189185
Para ejecutar las [pruebas](tests) necesitarás [Composer](http://getcomposer.org/download/)

.github/workflows/ci.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,11 @@ jobs:
4343
name: 'PHPUnit (PHP ${{ matrix.php }} - ${{ matrix.system }})'
4444
strategy:
4545
matrix:
46-
system: ['ubuntu-latest']
46+
system: ['ubuntu-latest', 'windows-latest']
4747
php:
4848
- '8.0'
4949
- '8.1'
50+
- '8.2'
5051
steps:
5152
- name: Checkout Code
5253
uses: actions/checkout@v3

CHANGELOG.md

+14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# CHANGELOG
22

3+
## [v2.0.2](https://github.com/josantonius/php-language-code/releases/tag/v2.0.2) (2022-XX-XX)
4+
5+
* The notation type in the test function names has been changed from camel to snake case for readability.
6+
7+
* Functions were added to document the methods and avoid confusion.
8+
9+
* Disabled the ´CamelCaseMethodName´ rule in ´phpmd.xml´ to avoid warnings about function names in tests.
10+
11+
* The alignment of the asterisks in the comments has been fixed.
12+
13+
* Tests for Windows have been added.
14+
15+
* Tests for PHP 8.2 have been added.
16+
317
## [v2.0.1](https://github.com/josantonius/php-language-code/releases/tag/v2.0.1) (2022-08-11)
418

519
* Improved documentation.

README.md

+12-20
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,16 @@ PHP library to get language name from code.
2626
- [TODO](#todo)
2727
- [Changelog](#changelog)
2828
- [Contribution](#contribution)
29-
- [Sponsor](#Sponsor)
29+
- [Sponsor](#sponsor)
3030
- [License](#license)
3131

3232
---
3333

3434
## Requirements
3535

36-
This library is compatible with the PHP versions: 8.0 | 8.1.
36+
Operating System: Linux | Windows.
37+
38+
PHP versions: 8.0 | 8.1 | 8.2.
3739

3840
## Installation
3941

@@ -62,56 +64,46 @@ clone https://github.com/josantonius/php-language-code.git
6264

6365
### LanguageCode Class
6466

65-
```php
66-
use Josantonius\LanguageCode\LanguageCode;
67-
```
68-
69-
Create object:
70-
71-
```php
72-
$languageCode = new LanguageCode();
73-
```
67+
`Josantonius\LanguageCode\LanguageCode`
7468

7569
Get all language codes as array:
7670

7771
```php
78-
$languageCode->all(): array
72+
public static function all(): array;
7973
```
8074

8175
Get language code from language name:
8276

8377
```php
84-
$languageCode->getCode(string $languageName): string|null
78+
public static function getCode(string $languageName): string|null;
8579
```
8680

8781
Get language name from language code:
8882

8983
```php
90-
$languageCode->getName(string $languageCode): string|null
84+
public static function getName(string $languageCode): string|null;
9185
```
9286

9387
### LanguageCodeCollection Class
9488

95-
```php
96-
use Josantonius\LanguageCode\LanguageCodeCollection;
97-
```
89+
`Josantonius\LanguageCode\LanguageCodeCollection`
9890

9991
Get all language codes as array:
10092

10193
```php
102-
LanguageCodeCollection::all(): array
94+
public static function all(): array
10395
```
10496

10597
Get language code from language name:
10698

10799
```php
108-
LanguageCodeCollection::getCode(string $languageName): string|null
100+
public static function getCode(string $languageName): string|null
109101
```
110102

111103
Get language name from language code:
112104

113105
```php
114-
LanguageCodeCollection::getName(string $languageCode): string|null
106+
public static function getName(string $languageCode): string|null
115107
```
116108

117109
## Usage

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"htmlCoverage": "vendor/bin/phpunit --coverage-html coverage",
5858
"phpcs": "vendor/bin/phpcs --standard=phpcs.xml $(find . -name '*.php');",
5959
"phpmd": "vendor/bin/phpmd src,tests text ./phpmd.xml",
60-
"phpunit": "vendor/bin/phpunit --colors=always;",
60+
"phpunit": "vendor/bin/phpunit",
6161
"tests": [
6262
"clear",
6363
"@phpmd",

phpmd.xml

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
<?xml version="1.0"?>
22
<ruleset name="PHPMD rule set"
3-
xmlns="http://pmd.sf.net/ruleset/1.0.0"
4-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5-
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0
6-
http://pmd.sf.net/ruleset_xml_schema.xsd"
7-
xsi:noNamespaceSchemaLocation="
3+
xmlns="http://pmd.sf.net/ruleset/1.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0
5+
http://pmd.sf.net/ruleset_xml_schema.xsd" xsi:noNamespaceSchemaLocation="
86
http://pmd.sf.net/ruleset_xml_schema.xsd">
97
<description>Coding standard.</description>
108

@@ -34,7 +32,7 @@
3432
<rule ref="rulesets/controversial.xml/Superglobals"/>
3533
<rule ref="rulesets/controversial.xml/CamelCaseClassName"/>
3634
<rule ref="rulesets/controversial.xml/CamelCasePropertyName"/>
37-
<rule ref="rulesets/controversial.xml/CamelCaseMethodName"/>
35+
<!--<rule ref="rulesets/controversial.xml/CamelCaseMethodName"/>-->
3836
<rule ref="rulesets/controversial.xml/CamelCaseParameterName"/>
3937
<rule ref="rulesets/controversial.xml/CamelCaseVariableName"/>
4038

src/LanguageCode.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22

33
/*
4-
* This file is part of https://github.com/josantonius/php-language-code repository.
5-
*
6-
* (c) Josantonius <hello@josantonius.dev>
7-
*
8-
* For the full copyright and license information, please view the LICENSE
9-
* file that was distributed with this source code.
10-
*/
4+
* This file is part of https://github.com/josantonius/php-language-code repository.
5+
*
6+
* (c) Josantonius <hello@josantonius.dev>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
1111

1212
namespace Josantonius\LanguageCode;
1313

src/LanguageCodeCollection.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22

33
/*
4-
* This file is part of https://github.com/josantonius/php-language-code repository.
5-
*
6-
* (c) Josantonius <hello@josantonius.dev>
7-
*
8-
* For the full copyright and license information, please view the LICENSE
9-
* file that was distributed with this source code.
10-
*/
4+
* This file is part of https://github.com/josantonius/php-language-code repository.
5+
*
6+
* (c) Josantonius <hello@josantonius.dev>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
1111

1212
namespace Josantonius\LanguageCode;
1313

tests/LanguageCodeTest.php

+14-12
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
<?php
22

33
/*
4-
* This file is part of https://github.com/josantonius/php-language-code repository.
5-
*
6-
* (c) Josantonius <hello@josantonius.dev>
7-
*
8-
* For the full copyright and license information, please view the LICENSE
9-
* file that was distributed with this source code.
10-
*/
4+
* This file is part of https://github.com/josantonius/php-language-code repository.
5+
*
6+
* (c) Josantonius <hello@josantonius.dev>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*
11+
* @phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
12+
*/
1113

1214
namespace Josantonius\LanguageCode\Tests;
1315

@@ -27,35 +29,35 @@ public function setUp(): void
2729
$this->languageCode = new LanguageCode();
2830
}
2931

30-
public function testShouldGetAllLanguageCodes(): void
32+
public function test_should_get_all_language_codes(): void
3133
{
3234
$this->assertNotEmpty($this->languageCode->all());
3335

3436
$this->assertNotEmpty($this->collection->all());
3537
}
3638

37-
public function testShouldGetLanguageCodeFromLanguageName(): void
39+
public function test_should_get_language_code_from_language_name(): void
3840
{
3941
$this->assertSame('es', $this->languageCode->getCode('Spanish'));
4042

4143
$this->assertSame('es', $this->collection->getCode('Spanish'));
4244
}
4345

44-
public function testShouldReturnNullWithUnknownLanguageName(): void
46+
public function test_should_return_null_with_unknown_language_name(): void
4547
{
4648
$this->assertNull($this->languageCode->getCode('foo'));
4749

4850
$this->assertNull($this->collection->getCode('foo'));
4951
}
5052

51-
public function testShouldGetLanguageNameFromLanguageCode(): void
53+
public function test_should_get_language_name_from_language_code(): void
5254
{
5355
$this->assertSame('Spanish', $this->languageCode->getName('es'));
5456

5557
$this->assertSame('Spanish', $this->collection->getName('es'));
5658
}
5759

58-
public function testShouldReturnNullWithUnknownLanguageCode(): void
60+
public function test_should_return_null_with_unknown_language_code(): void
5961
{
6062
$this->assertNull($this->languageCode->getName('bar'));
6163

0 commit comments

Comments
 (0)