Ipvalidate   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 19
ccs 13
cts 13
cp 1
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getUrl() 0 13 2
A __construct() 0 3 1
1
<?php
2
3
namespace Osln\Weather;
4
5
use Anax\Commons\ContainerInjectableInterface;
6
use Anax\Commons\ContainerInjectableTrait;
7
8
class Ipvalidate
9
{
10 6
    public function __construct()
11
    {
12 6
        $this->config = new LoadConfig();
0 ignored issues
show
Bug Best Practice introduced by
The property config does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
13 6
    }
14 4
    public function getUrl($search)
15
    {
16 4
        $url = null;
17 4
        $key = null;
18 4
        if (filter_var($search, FILTER_VALIDATE_IP)) {
19 4
            $key = $this->config->getKey("ipstack");
20 4
            $url = "http://api.ipstack.com/%2\$s?access_key=%1\$s";
21
        } else {
22 4
            $url = "http://open.mapquestapi.com/nominatim/v1/search.php?q=%2\$s&limit=1&format=json&key=%1\$s";
23 4
            $key = $this->config->getKey("mapquest");
24
        }
25 4
        $urlFinal = sprintf($url, $key, $search);
26 4
        return $urlFinal;
27
    }
28
}
29