1
0
mirror of https://github.com/halaxa/json-machine.git synced 2025-01-17 21:18:23 +01:00

Fixed guzzle example

This commit is contained in:
Filip Halaxa 2019-02-28 10:29:13 +01:00
parent 1c70b6cd84
commit 1c02d8e761
3 changed files with 6 additions and 4 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
.idea
/vendor/
composer.lock

View File

@ -18,7 +18,8 @@
"ext-json": "*"
},
"require-dev": {
"phpunit/phpunit": "*"
"phpunit/phpunit": "*",
"guzzlehttp/guzzle": "^6"
},
"autoload" : {
"psr-4": {"JsonMachine\\": "src/"}

View File

@ -6,6 +6,6 @@ $client = new \GuzzleHttp\Client();
$respose = $client->request('GET', 'https://httpbin.org/anything?key=value');
// Gets PHP stream resource from Guzzle stream
$phpStream = \GuzzleHttp\Psr7\StreamWrapper::getResource($respose->getBody());
$result = iterator_to_array(\JsonMachine\JsonMachine::fromStream($phpStream));
assert($result['args'] == ['key' => 'value']);
foreach (\JsonMachine\JsonMachine::fromStream($phpStream) as $key => $value) {
var_dump([$key, $value]);
}