Skip to content

Commit 4fa7ff4

Browse files
committed
Library modified to be compatible with PHP 5.6 or higher
1 parent 3073646 commit 4fa7ff4

File tree

8 files changed

+29
-22
lines changed

8 files changed

+29
-22
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# CHANGELOG
22

3+
## 1.1.0 - 2017-01-30
4+
* Compatible with PHP 5.6 or higher.
5+
6+
## 1.0.0-v - 2017-01-30
7+
* 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.
8+
39
## 1.0.0 - 2017-01-12
410
* Added `Josantonius\LanguageCode\LanguageCode` class.
511
* Added `Josantonius\LanguageCode\LanguageCode::load()` method.

README-ES.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ Para instalar PHP LanguageCode library, simplemente escribe:
3232

3333
### Requisitos
3434

35-
Esta ĺibrería es soportada por versiones de PHP 7.0 o superiores y es compatible con versiones de HHVM 3.0 o superiores.
36-
37-
Para utilizar esta librería en HHVM (HipHop Virtual Machine) tendrás que activar los tipos escalares. Añade la siguiente ĺínea "hhvm.php7.scalar_types = true" en tu "/etc/hhvm/php.ini".
35+
Esta ĺibrería es soportada por versiones de PHP 5.6 o superiores y es compatible con versiones de HHVM 3.0 o superiores.
3836

3937
### Cómo empezar y ejemplos
4038

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ To install PHP LanguageCode library, simply:
3232

3333
### Requirements
3434

35-
This library is supported by PHP versions 7.0 or higher and is compatible with HHVM versions 3.0 or higher.
36-
37-
To use this library in HHVM (HipHop Virtual Machine) you will have to activate the scalar types. Add the following line "hhvm.php7.scalar_types = true" in your "/etc/hhvm/php.ini".
35+
This library is supported by PHP versions 5.6 or higher and is compatible with HHVM versions 3.0 or higher.
3836

3937
### Quick Start and Examples
4038

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "josantonius/languagecode",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"type": "library",
55
"description": "List of 217 language codes: ISO 639-1.",
66
"keywords": [
@@ -22,7 +22,7 @@
2222
"minimum-stability": "dev",
2323
"prefer-stable" : true,
2424
"require": {
25-
"php" : ">=7.0"
25+
"php" : ">=5.6"
2626
},
2727
"autoload": {
2828
"psr-4": {

src/Exception/LanguageCodeException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php declare(strict_types=1);
1+
<?php
22
/**
33
* List of 217 language codes: ISO 639-1.
44
*
@@ -35,7 +35,7 @@ class LanguageCodeException extends \Exception {
3535
* @param int $error → error code (Optional)
3636
* @param int $status → HTTP response status code (Optional)
3737
*/
38-
public function __construct(string $msg = '', int $error = 0, int $status = 0) {
38+
public function __construct($msg = '', $error = 0, $status = 0) {
3939

4040
$this->message = $msg;
4141
$this->code = $error;

src/LanguageCode.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php declare(strict_types=1);
1+
<?php
22
/**
33
* List of 217 language codes: ISO 639-1.
44
*
@@ -8,9 +8,9 @@
88
* @author Josantonius - info@josantonius.com
99
* @copyright Copyright (c) 2017 JST PHP Framework
1010
* @license https://opensource.org/licenses/MIT - The MIT License (MIT)
11-
* @version 1.0.0
11+
* @version 1.1.0
1212
* @link https://github.com/Josantonius/PHP-LanguageCode
13-
* @since File available since 1.0.0 - Update: 2017-01-12
13+
* @since File available since 1.0.0 - Update: 2017-01-30
1414
*/
1515

1616
namespace Josantonius\LanguageCode;
@@ -40,7 +40,7 @@ class LanguageCode {
4040
*
4141
* @return array → language code
4242
*/
43-
protected static function load(): array {
43+
protected static function load() {
4444

4545
if (is_null(static::$lamguageCodes)) {
4646

@@ -67,11 +67,16 @@ protected static function load(): array {
6767
*
6868
* @return string → country name
6969
*/
70-
public static function getLanguageFromCode(string $languageCode): string {
70+
public static function getLanguageFromCode($languageCode) {
7171

7272
static::load();
7373

74-
return static::$lamguageCodes[$languageCode] ?? "undefined";
74+
if (!isset(static::$lamguageCodes[$languageCode])) {
75+
76+
static::$lamguageCodes[$languageCode] = "undefined";
77+
}
78+
79+
return static::$lamguageCodes[$languageCode];
7580
}
7681

7782
/**
@@ -83,7 +88,7 @@ public static function getLanguageFromCode(string $languageCode): string {
8388
*
8489
* @return string → language code
8590
*/
86-
public static function getCodeFromLanguage(string $language): string {
91+
public static function getCodeFromLanguage($language) {
8792

8893
static::load();
8994

@@ -102,7 +107,7 @@ public static function getCodeFromLanguage(string $language): string {
102107
*
103108
* @return array → language codes and language names
104109
*/
105-
public static function getAll(): array {
110+
public static function getAll() {
106111

107112
return static::load();
108113
}

src/resources/languageCodes.jsond

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
"_author" : "Josantonius - info@josantonius.com",
88
"_copyright" : "Copyright (c) 2016 JST PHP Framework",
99
"_license" : "http://opensource.org/licenses/MIT - The MIT License (MIT)",
10-
"_version" : "1.0.0",
10+
"_version" : "1.1.0",
1111
"_link" : "http://github.com/josantonius/PHP-MimeType",
12-
"_since" : "File available since 1.0.0 - Update: 2017-01-12",
12+
"_since" : "File available since 1.0.0 - Update: 2017-01-30",
1313
"_comment" : "Compiled from https://wikipedia.org/wiki/List_of_ISO_639-1_codes"
1414
},
1515

tests/LanguageCodeTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
* @author Josantonius - info@josantonius.com
99
* @copyright Copyright (c) 2017 JST PHP Framework
1010
* @license https://opensource.org/licenses/MIT - The MIT License (MIT)
11-
* @version 1.0.0
11+
* @version 1.1.0
1212
* @link https://github.com/Josantonius/PHP-LanguageCode
13-
* @since File available since 1.0.0 - Update: 2017-01-12
13+
* @since File available since 1.0.0 - Update: 2017-01-30
1414
*/
1515

1616
namespace Josantonius\LanguageCode\Tests;

0 commit comments

Comments
 (0)