Ivao::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
namespace Ballen\Metar\Providers;
3
4
/**
5
 * Metar
6
 *
7
 * Metar is a PHP library for retrieveing weather reports (METAR infomation),
8
 * the library supports multiple 'METAR prodivers' including NOAA, VATSIM and IVAO.
9
 *
10
 * @author Bobby Allen <[email protected]>
11
 * @license http://www.gnu.org/licenses/gpl-3.0.html
12
 * @link https://github.com/allebb/metar
13
 * @link http://www.bobbyallen.me
14
 *
15
 */
16
use \Ballen\Metar\Helpers\MetarHTTPClient;
17
18
/**
19
 * METAR service provided by the IVAO (The International Virtual Aviation Organisation)
20
 * @link https://www.ivao.aero/
21
 */
22
class Ivao extends MetarHTTPClient implements MetarProviderInterface
23
{
24
25
    private $serviceUrl = 'http://wx.ivao.aero/metar.php/?id={{_ICAO_}}';
26
    private $icao;
27
28 2
    public function __construct($icao)
29
    {
30 2
        $this->icao = $icao;
31 2
    }
32
33 2
    private function getMetarDataString()
34
    {
35
36 2
        $data = $this->getMetarAPIResponse(str_replace('{{_ICAO_}}', $this->icao, $this->serviceUrl));
37 2
        return $data;
38
    }
39
40 2
    public function __toString()
41
    {
42 2
        return $this->getMetarDataString();
43
    }
44
}
45