Code

< 40 %
40-60 %
> 60 %
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Geocoder 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 Geocoder;
14
15
use Geocoder\Query\GeocodeQuery;
16
use Geocoder\Query\ReverseQuery;
17
18
/**
19
 * A trait that turns a Provider into a Geocoder.
20
 *
21
 * @author Tobias Nyholm <[email protected]>
22
 */
23
trait GeocoderTrait
24
{
25
    abstract public function geocodeQuery(GeocodeQuery $query): Collection;
26
27
    abstract public function reverseQuery(ReverseQuery $query): Collection;
28
29 2
    public function geocode(string $value): Collection
30
    {
31 2
        return $this->geocodeQuery(GeocodeQuery::create($value));
32
    }
33
34 2
    public function reverse(float $latitude, float $longitude): Collection
35
    {
36 2
        return $this->reverseQuery(ReverseQuery::fromCoordinates($latitude, $longitude));
37
    }
38
}
39