Author: Jens Wiese (jens@howtrueisfalse.de)
Inheritance: extends Geocoder\Provider\AbstractProvider, implements Geocoder\Provider\LocaleAwareProvider, use trait Geocoder\Provider\LocaleTrait
示例#1
0
 /**
  * @return bool|int
  */
 public function getId()
 {
     $id = $this->getIdFromSignedCookie();
     if (false === $id) {
         $ipAddress = $this->request->getClientIp();
         $geocoderResult = null;
         if ($this->geocoder) {
             try {
                 $geocoderResult = $this->geocoder->geocode($ipAddress)->first();
             } catch (NoResultException $e) {
             }
         }
         $id = $this->dbGateway->insertUserInformation($ipAddress, $_SERVER['HTTP_USER_AGENT'], php_sapi_name(), $geocoderResult);
         $this->writeSignedCookie($id);
     }
     return $id;
 }
示例#2
0
 /**
  * @expectedException \Geocoder\Exception\NoResult
  * @expectedExceptionMessage No results found for IP address 74.200.247.59
  */
 public function testRetrievingGeodataNotExistingLocation()
 {
     $adapterReturn = new NoResult('No results found for IP address 74.200.247.59');
     $adapter = $this->getGeoIP2AdapterMock($adapterReturn);
     $provider = new GeoIP2($adapter);
     $provider->geocode('74.200.247.59');
 }