Completed
Push — master ( 263935...5461a9 )
by Witold
13s queued 11s
created

Geoip::getGeoip()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
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