Skip to content

Commit

Permalink
added guzzlehttp/guzzle, removed adinan-cenci/simple-request, minor a…
Browse files Browse the repository at this point in the history
…djustments to the documentation
  • Loading branch information
Adinan Cenci committed Nov 1, 2021
1 parent c1b2add commit b96df49
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.0.1] - 2021-11-01

### Changed

Added `guzzlehttp/guzzle` to the project, replacing my own `adinan-cenci/simple-request`.

## [2.0.0] - 2021-05-22

### Changed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ All the methods will return strings formated accordingly to the `$format` proper
### \AdinanCenci\RadioBrowser\RadioBrowser

`RadioBrowser` is a convenient wrapper for `RarioBrowserApi` class, it has the same methods of the latter,
but instead of returning strings, either arrays or stdObjects will be returned, depending on the `$associative` property.
but instead of returning strings, it will return either arrays or stdObjects, depending on the `$associative` property, this class only exists for conveniency sake.

| Parameter | Type | Default | Description |
| ------------ | ------------ | ----------------------------------- | ------------------------------------------------------------ |
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "library",
"keywords": ["radio", "music"],
"license": "MIT",
"version": "2.0.0",
"version": "2.0.1",
"authors": [
{
"name": "Adinan Cenci",
Expand All @@ -23,8 +23,8 @@
}
],
"require": {
"php": ">=7.0",
"adinan-cenci/simple-request": "^1.1.0"
"php": ">=7.0",
"guzzlehttp/guzzle": "^7.4"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 1 addition & 3 deletions src/RadioBrowser.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?php
namespace AdinanCenci\RadioBrowser;

use \AdinanCenci\SimpleRequest\Request;

/**
* This is simply a wrapper for the RadioBrowserApi class, returning the data
* decoded in associative arrays ( or stdClass objects ) for the sake of convienency.
* decoded in associative arrays ( or stdClass objects ) for the sake of conveniency.
*/

class RadioBrowser
Expand Down
14 changes: 6 additions & 8 deletions src/RadioBrowserApi.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace AdinanCenci\RadioBrowser;

use \AdinanCenci\SimpleRequest\Request;
use \GuzzleHttp\Client;

class RadioBrowserApi
{
Expand Down Expand Up @@ -387,13 +387,11 @@ protected function getStationsBy($url, $order = 'name', $reverse = false, $hideB

protected function fetch($url, $fields = array())
{
$r = new Request($url);
$r->fields($fields);
$client = new Client();

$response = $r->request();

if ($response->code != 200) {
throw new \Exception('Error requesting "'.$response->url.'", code: '.$response->code, 1);
$response = $client->request('GET', $url, ['query' => $fields]);
if ($response->getStatusCode() != 200) {
throw new \Exception('Error requesting "'.$url.'", code: '.$response->getStatusCode(), 1);
}

return $response;
Expand All @@ -402,7 +400,7 @@ protected function fetch($url, $fields = array())
protected function fetchBody($url, $fields = array())
{
$response = $this->fetch($url, $fields);
return $response->body;
return $response->getBody();
}

//------------------------------------
Expand Down

0 comments on commit b96df49

Please sign in to comment.