Completed
Push — master ( ef74a9...e368c4 )
by Tobias
04:49
created

ProviderFactory/MapzenFactory.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the BazingaGeocoderBundle package.
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @license    MIT License
11
 */
12
13
namespace Bazinga\GeocoderBundle\ProviderFactory;
14
15
use Geocoder\Provider\Mapzen\Mapzen;
16
use Geocoder\Provider\Provider;
17
use Http\Discovery\HttpClientDiscovery;
18
use Symfony\Component\OptionsResolver\OptionsResolver;
19
20 1
@trigger_error('Bazinga\GeocoderBundle\ProviderFactory\MapzenFactory is deprecated since 5.6, to be removed in 6.0. See https://github.com/geocoder-php/Geocoder/issues/808', E_USER_DEPRECATED);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
21
22
/**
23
 * @deprecated since 5.6, to be removed in 6.0. See https://github.com/geocoder-php/Geocoder/issues/808
24
 */
25 View Code Duplication
final class MapzenFactory extends AbstractFactory
26
{
27
    protected static $dependencies = [
28
        ['requiredClass' => Mapzen::class, 'packageName' => 'geocoder-php/mapzen-provider'],
29
    ];
30
31 1
    protected function getProvider(array $config): Provider
32
    {
33 1
        $httplug = $config['httplug_client'] ?: HttpClientDiscovery::find();
34
35 1
        return new Mapzen($httplug, $config['api_key']);
36
    }
37
38 1
    protected static function configureOptionResolver(OptionsResolver $resolver)
39
    {
40 1
        $resolver->setDefaults([
41 1
            'httplug_client' => null,
42
        ]);
43
44 1
        $resolver->setRequired('api_key');
45 1
        $resolver->setAllowedTypes('httplug_client', ['object', 'null']);
46 1
        $resolver->setAllowedTypes('api_key', ['string']);
47 1
    }
48
}
49