for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Ballen\Metar\Helpers;
use GuzzleHttp\Client as HttpClient;
use \Exception;
/**
* Metar
*
* Metar is a PHP library for retrieveing weather reports (METAR infomation),
* the library supports multiple 'METAR prodivers' including NOAA, VATSIM and IVAO.
* @author Bobby Allen <[email protected]>
* @license http://www.gnu.org/licenses/gpl-3.0.html
* @link https://github.com/allebb/metar
* @link http://www.bobbyallen.me
*/
class MetarHTTPClient
{
* Optional Guzzle Client configuration.
* @var array
protected $guzzleConf = [];
* HTTP Client
* @param array $config Optional Guzzle configuration.
public function __construct($config = [])
$this->guzzleConf = $config;
}
* Make a HTTP request and retrieve the body.
* @param string $url The URL to request
* @return \Psr\Http\Message\StreamInterface
public function getMetarAPIResponse($url)
$client = new HttpClient($this->guzzleConf);
$response = $client->get($url);
return $response->getBody()
return $response->getBody()->getContents()
string
Psr\Http\Message\StreamInterface
->getContents();