MetarHTTPClient   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 1 Features 0
Metric Value
eloc 7
c 3
b 1
f 0
dl 0
loc 29
ccs 8
cts 8
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getMetarAPIResponse() 0 6 1
A __construct() 0 3 1
1
<?php
2
namespace Ballen\Metar\Helpers;
3
4
use GuzzleHttp\Client as HttpClient;
5
use \Exception;
6
7
/**
8
 * Metar
9
 *
10
 * Metar is a PHP library for retrieveing weather reports (METAR infomation),
11
 * the library supports multiple 'METAR prodivers' including NOAA, VATSIM and IVAO.
12
 *
13
 * @author Bobby Allen <[email protected]>
14
 * @license http://www.gnu.org/licenses/gpl-3.0.html
15
 * @link https://github.com/allebb/metar
16
 * @link http://www.bobbyallen.me
17
 *
18
 */
19
class MetarHTTPClient
20
{
21
22
    /**
23
     * Optional Guzzle Client configuration.
24
     * @var array
25
     */
26
    protected $guzzleConf = [];
27
28
    /**
29
     * HTTP Client
30
     * @param array $config Optional Guzzle configuration.
31
     */
32 6
    public function __construct($config = [])
33
    {
34 6
        $this->guzzleConf = $config;
35 6
    }
36
37
    /**
38
     * Make a HTTP request and retrieve the body.
39
     * @param string $url The URL to request
40
     * @return \Psr\Http\Message\StreamInterface
41
     */
42 12
    public function getMetarAPIResponse($url)
43
    {
44 12
        $client = new HttpClient($this->guzzleConf);
45 12
        $response = $client->get($url);
46 8
        return $response->getBody()
0 ignored issues
show
Bug Best Practice introduced by
The expression return $response->getBody()->getContents() returns the type string which is incompatible with the documented return type Psr\Http\Message\StreamInterface.
Loading history...
47 8
                ->getContents();
48
    }
49
}
50