Skip to content

Commit

Permalink
Merge pull request #3 from josantonius/release/v2.0.2
Browse files Browse the repository at this point in the history
Release/v2.0.2
  • Loading branch information
josantonius authored Sep 29, 2022
2 parents dcb5e5a + de179c6 commit 9a32cd2
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 73 deletions.
34 changes: 15 additions & 19 deletions .github/lang/es-ES/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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/)
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
32 changes: 12 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 4 additions & 6 deletions phpmd.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<?xml version="1.0"?>
<ruleset name="PHPMD rule set"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0
http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0
http://pmd.sf.net/ruleset_xml_schema.xsd" xsi:noNamespaceSchemaLocation="
http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>Coding standard.</description>

Expand Down Expand Up @@ -34,7 +32,7 @@
<rule ref="rulesets/controversial.xml/Superglobals"/>
<rule ref="rulesets/controversial.xml/CamelCaseClassName"/>
<rule ref="rulesets/controversial.xml/CamelCasePropertyName"/>
<rule ref="rulesets/controversial.xml/CamelCaseMethodName"/>
<!--<rule ref="rulesets/controversial.xml/CamelCaseMethodName"/>-->
<rule ref="rulesets/controversial.xml/CamelCaseParameterName"/>
<rule ref="rulesets/controversial.xml/CamelCaseVariableName"/>

Expand Down
14 changes: 7 additions & 7 deletions src/LanguageCode.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php

/*
* This file is part of https://github.com/josantonius/php-language-code repository.
*
* (c) Josantonius <[email protected]>
*
* 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 <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Josantonius\LanguageCode;

Expand Down
14 changes: 7 additions & 7 deletions src/LanguageCodeCollection.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php

/*
* This file is part of https://github.com/josantonius/php-language-code repository.
*
* (c) Josantonius <[email protected]>
*
* 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 <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Josantonius\LanguageCode;

Expand Down
26 changes: 14 additions & 12 deletions tests/LanguageCodeTest.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<?php

/*
* This file is part of https://github.com/josantonius/php-language-code repository.
*
* (c) Josantonius <[email protected]>
*
* 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 <[email protected]>
*
* 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;

Expand All @@ -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'));

Expand Down

0 comments on commit 9a32cd2

Please sign in to comment.