forked from geocoder-php/BazingaGeocoderBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPluginProviderFactory.php
More file actions
42 lines (36 loc) · 1.4 KB
/
PluginProviderFactory.php
File metadata and controls
42 lines (36 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
declare(strict_types=1);
/*
* This file is part of the BazingaGeocoderBundle package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT License
*/
namespace Bazinga\GeocoderBundle\ProviderFactory;
use Geocoder\Plugin\Plugin;
use Geocoder\Plugin\PluginProvider;
use Geocoder\Provider\Provider;
/**
* This factory creates a PluginProvider.
*
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
*/
final class PluginProviderFactory
{
/**
* @param Plugin[] $plugins
* @param callable(array<mixed>):Provider|ProviderFactoryInterface $factory
* @param array<mixed> $config config to the client factory
* @param array{max_restarts?: int<0, max>} $pluginProviderOptions config forwarded to the PluginProvider
*/
public static function createPluginProvider(array $plugins, callable|ProviderFactoryInterface $factory, array $config, array $pluginProviderOptions = []): PluginProvider
{
if ($factory instanceof ProviderFactoryInterface) {
$client = $factory->createProvider($config);
} else {
$client = $factory($config);
}
return new PluginProvider($client, $plugins, $pluginProviderOptions);
}
}