$provider) { if (!($provider instanceof GetLatLngFromAddressInterface)) { throw new \InvalidArgumentException( 'LatLng provider ' . $providerCode . ' must implement ' . GetLatLngFromAddressInterface::class ); } } $this->providers = $providers; $this->getDistanceProviderCode = $getDistanceProviderCode; } /** * @inheritdoc * @throws NoSuchLatLngFromAddressProviderException */ public function execute(AddressInterface $address): LatLngInterface { $code = $this->getDistanceProviderCode->execute(); if (!isset($this->providers[$code])) { throw new NoSuchLatLngFromAddressProviderException( __('No such latitude and longitude from address provider: %1', $code) ); } return $this->providers[$code]->execute($address); } }