Geoip::__toString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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