Geoip   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 26
rs 10
c 1
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __invoke() 0 4 1
A __toString() 0 4 1
1
<?php
2
3
namespace ZfSnapGeoip\View\Helper;
4
5
use Zend\View\Helper\AbstractHelper;
6
use ZfSnapGeoip\Entity\RecordInterface;
7
use ZfSnapGeoip\Service\Geoip as GeoipService;
8
9
/**
10
 * Geoip view helper
11
 *
12
 * @author Witold Wasiczko <[email protected]>
13
 */
14
class Geoip extends AbstractHelper
15
{
16
    private $geoip;
17
18
    public function __construct(GeoipService $geoip)
19
    {
20
        $this->geoip = $geoip;
21
    }
22
23
    /**
24
     * @param string $ipAddress
25
     * @return RecordInterface
26
     */
27
    public function __invoke($ipAddress = null)
28
    {
29
        return $this->geoip->getRecord($ipAddress);
30
    }
31
32
    /**
33
     * @return string
34
     */
35
    public function __toString()
36
    {
37
        return (string) $this->geoip->getRecord();
38
    }
39
}
40