Skip to content

Commit 3a4221b

Browse files
committed
Library modified to be compatible with PHP 5.6 or higher
1 parent a612c87 commit 3a4221b

File tree

8 files changed

+29
-25
lines changed

8 files changed

+29
-25
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 - 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 - 2016-12-19
410
* Added `Josantonius\HTTPStatusCode\HTTPStatusCode` class.
511
* Added `Josantonius\HTTPStatusCode\HTTPStatusCode::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 HTTPStatusCode 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 HTTPStatusCode 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/httpstatuscode",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"type": "library",
55
"description": "PHP library to get the meaning from HTTP response status codes.",
66
"keywords": [
@@ -21,7 +21,7 @@
2121
"minimum-stability": "dev",
2222
"prefer-stable" : true,
2323
"require": {
24-
"php" : ">=7.0"
24+
"php" : ">=5.6"
2525
},
2626
"autoload": {
2727
"psr-4": {

src/Exception/HTTPStatusCodeException.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php declare(strict_types=1);
1+
<?php
22
/**
33
* PHP library to get the meaning from HTTP response status codes.
44
*
@@ -8,9 +8,9 @@
88
* @author Josantonius - info@josantonius.com
99
* @copyright Copyright (c) 2016 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-HTTPStatusCode
13-
* @since File available since 1.0.0 - Update: 2016-12-19
13+
* @since File available since 1.0.0 - Update: 2017-01-30
1414
*/
1515

1616
namespace Josantonius\HTTPStatusCode\Exception;
@@ -35,7 +35,7 @@ class HTTPStatusCodeException 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/HTTPStatusCode.php

Lines changed: 10 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
* PHP library to get the meaning from HTTP response status codes.
44
*
@@ -8,9 +8,9 @@
88
* @author Josantonius - info@josantonius.com
99
* @copyright Copyright (c) 2016 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-HTTPStatusCode
13-
* @since File available since 1.0.0 - Update: 2016-12-19
13+
* @since File available since 1.0.0 - Update: 2017-01-30
1414
*/
1515

1616
namespace Josantonius\HTTPStatusCode;
@@ -51,7 +51,7 @@ class HTTPStatusCode {
5151
*
5252
* @return array → HTTP response status code
5353
*/
54-
protected static function load(string $lang = 'en'): array {
54+
protected static function load($lang = 'en') {
5555

5656
if ($lang != static::$lang) {
5757

@@ -89,11 +89,13 @@ protected static function load(string $lang = 'en'): array {
8989
*
9090
* @return string → HTTP status code definition
9191
*/
92-
public static function get(int $code, string $lang = 'en', string $size = 'short'): string {
92+
public static function get($code, $lang = 'en', $size = 'short') {
9393

9494
static::load($lang);
9595

96-
return static::$status[$code][$size] ?? "Undefined";
96+
$result = (isset(static::$status[$code][$size])) ? static::$status[$code][$size] : "Undefined";
97+
98+
return $result;
9799
}
98100

99101
/**
@@ -105,8 +107,8 @@ public static function get(int $code, string $lang = 'en', string $size = 'short
105107
*
106108
* @return array → all definitions of HTTP response codes
107109
*/
108-
public static function getAll(string $lang = 'en'): array {
110+
public static function getAll($lang = 'en') {
109111

110112
return static::load($lang);
111113
}
112-
}
114+
}

src/resources/http-status-code.jsond

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) 2016 JST PHP Framework",
1010
"_license" : "http://opensource.org/licenses/MIT - The MIT License (MIT)",
11-
"_version" : "1.0.0",
11+
"_version" : "1.1.0",
1212
"_link" : "http://github.com/josantonius/PHP-HTTPStatusCode",
13-
"_since" : "File available since 1.0.0 - Update: 2016-12-19",
13+
"_since" : "File available since 1.0.0 - Update: 2017-01-30",
1414
"_comment" : "Compiled from wikipedia.org/wiki/List_of_HTTP_status_codes"
1515
},
1616

tests/HTTPStatusCodeTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
* @author Josantonius - info@josantonius.com
99
* @copyright Copyright (c) 2016 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-HTTPStatusCode
13-
* @since File available since 1.0.0 - Update: 2016-12-19
13+
* @since File available since 1.0.0 - Update: 2017-01-30
1414
*/
1515

1616
namespace Josantonius\HTTPStatusCode\Tests;
@@ -143,4 +143,4 @@ public static function testGetAllES() {
143143

144144
echo '<pre>'; var_dump(HTTPStatusCode::getAll('es')); echo '</pre>';
145145
}
146-
}
146+
}

0 commit comments

Comments
 (0)