IPStackFinder   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 32
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A get() 0 11 1
1
<?php
2
3
namespace Arimolzer\IPStackFinder;
4
5
use GuzzleHttp\Client;
6
7
/**
8
 * Class IPStackFinder
9
 * @package Arimolzer\IPStackFinder
10
 */
11
class IPStackFinder
12
{
13
    /** @var Client $client */
14
    public $client;
15
16
    /**
17
     * IPStackHelper constructor.
18
     * @param Client $client
19
     */
20
    public function __construct(Client $client)
21
    {
22
        $this->client = $client;
23
    }
24
25
    /**
26
     * Get the API response from ipstack.com and return in php associative array format.
27
     * @param $ipAddress
28
     * @return array
29
     * @throws \GuzzleHttp\Exception\GuzzleException
30
     */
31
    public function get($ipAddress) : array
32
    {
33
        /** @var string $responseJson */
34
        $responseJson = $this->client
35
            ->request('GET', $ipAddress)
36
            ->getBody()
37
            ->getContents();
38
39
        /** @var array */
40
        return json_decode($responseJson, true);
41
    }
42
}
43