Skip to content

Commit eed485a

Browse files
authored
Merge pull request #27 from amcsi/master
Add support for PHP 7.4, but drop support for below PHP 7.1
2 parents ab412ad + a4bc6ef commit eed485a

File tree

5 files changed

+40
-44
lines changed

5 files changed

+40
-44
lines changed

.travis.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ dist: trusty
33
language: php
44

55
php:
6-
- 5.6
7-
- 7.0
86
- 7.1
7+
- 7.2
8+
- 7.3
9+
- 7.4
910

1011
sudo: false
1112

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ When you are developing JSON API sometimes you need to debug it, but if you will
5858

5959
To get the latest version of Laravel Laravel-API-Debugger, simply add the following line to the require block of your `composer.json` file.
6060

61+
For PHP >= 7.1:
62+
63+
```
64+
"lanin/laravel-api-debugger": "^4.0"
65+
```
66+
67+
For PHP < 7.1:
68+
6169
```
6270
"lanin/laravel-api-debugger": "^3.0"
6371
```

composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
}
1212
],
1313
"require": {
14-
"php": ">=5.6.0",
14+
"php": ">=7.1",
1515
"illuminate/support": ">=5.4.0"
1616
},
1717
"require-dev": {
1818
"orchestra/testbench": ">=3.4.0",
19-
"phpunit/phpunit": ">=5.7",
20-
"mockery/mockery": "0.9.*"
19+
"phpunit/phpunit": "^7",
20+
"mockery/mockery": "^1.3.1"
2121
},
2222
"autoload": {
2323
"psr-4": {

src/Collections/QueriesCollection.php

+25-38
Original file line numberDiff line numberDiff line change
@@ -119,44 +119,31 @@ protected function convertAttribute($attribute)
119119
try {
120120
return (string) $attribute;
121121
} catch (\Throwable $e) {
122-
return $this->handleConvertAttributeException($attribute);
123-
} catch (\Exception $e) {
124-
return $this->handleConvertAttributeException($attribute);
125-
}
126-
}
127-
128-
/**
129-
* Handle convert attribute exception and convert attribute to string.
130-
*
131-
* @param mixed $attribute
132-
* @return string
133-
*/
134-
protected function handleConvertAttributeException($attribute)
135-
{
136-
switch (true) {
137-
// Handle DateTime attribute pass.
138-
case $attribute instanceof \DateTime:
139-
return $attribute->format('Y-m-d H:i:s');
140-
141-
// Handle callables.
142-
case $attribute instanceof \Closure:
143-
return $this->convertAttribute($attribute());
144-
145-
// Handle arrays using json by default or print_r if error occurred.
146-
case is_array($attribute):
147-
$json = json_encode($attribute);
148-
149-
return json_last_error() === JSON_ERROR_NONE
150-
? $json
151-
: print_r($attribute);
152-
153-
// Handle all other object.
154-
case is_object($attribute):
155-
return get_class($attribute);
156-
157-
// For all unknown.
158-
default:
159-
return '?';
122+
switch (true) {
123+
// Handle DateTime attribute pass.
124+
case $attribute instanceof \DateTime:
125+
return $attribute->format('Y-m-d H:i:s');
126+
127+
// Handle callables.
128+
case $attribute instanceof \Closure:
129+
return $this->convertAttribute($attribute());
130+
131+
// Handle arrays using json by default or print_r if error occurred.
132+
case is_array($attribute):
133+
$json = json_encode($attribute);
134+
135+
return json_last_error() === JSON_ERROR_NONE
136+
? $json
137+
: print_r($attribute);
138+
139+
// Handle all other object.
140+
case is_object($attribute):
141+
return get_class($attribute);
142+
143+
// For all unknown.
144+
default:
145+
return '?';
146+
}
160147
}
161148
}
162149
}

tests/TestCase.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ abstract class TestCase extends BaseTestCase
1010
/**
1111
* Setup the test environment.
1212
*/
13-
public function setUp()
13+
public function setUp(): void
1414
{
1515
parent::setUp();
1616
}

0 commit comments

Comments
 (0)