Geocoder\Provider\Chain::reverse PHP Method

reverse() public method

{@inheritDoc}
public reverse ( $latitude, $longitude )
    public function reverse($latitude, $longitude)
    {
        $exceptions = [];
        foreach ($this->providers as $provider) {
            try {
                return $provider->reverse($latitude, $longitude);
            } catch (InvalidCredentials $e) {
                throw $e;
            } catch (\Exception $e) {
                $exceptions[] = $e;
            }
        }
        throw new ChainNoResult(sprintf('No provider could reverse coordinates: %f, %f.', $latitude, $longitude), $exceptions);
    }

Usage Example

Exemplo n.º 1
0
 public function testReverseThrowsChainNoResult()
 {
     $mockOne = $this->getMock('Geocoder\\Provider\\Provider');
     $mockOne->expects($this->exactly(2))->method('reverse')->will($this->returnCallback(function () {
         throw new \Exception();
     }));
     $chain = new Chain(array($mockOne, $mockOne));
     try {
         $chain->reverse('11', '22');
     } catch (ChainNoResult $e) {
         $this->assertCount(2, $e->getExceptions());
     }
 }