Example #1
0
 /**
  * Returns the stat handler value.
  *
  * @return string
  */
 public function getValue()
 {
     $location = $this->geoIp->getGeoIpLocation($this->statHandlerObject->getIp());
     if ($location) {
         return $location->getCountryCode();
     }
 }
Example #2
0
 /**
  * @param $query
  * @param $expectedResult
  *
  * @throws \Exception
  * @dataProvider provider
  */
 public function testGetGeoIpLocation($query, $expectedResult)
 {
     $instance = new GeoIp(new NullProvider());
     try {
         $result = $instance->getGeoIpLocation($query);
         if ($result == true) {
             $this->assertInstanceOf('Webiny\\GeoIp\\Location', $result);
             $this->assertTrue($expectedResult);
         } else {
             $this->assertFalse($expectedResult);
         }
     } catch (GeoIpException $e) {
         $this->assertSame('exception', $expectedResult);
     }
 }