<commit_before><?php

/*
 * This file is part of the Ivory Google Map package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please read the LICENSE
 * file that was distributed with this source code.
 */

namespace Ivory\GoogleMap\Service\Geocoder;

use Geocoder\Provider\LocaleAwareProvider;
use Geocoder\Provider\LocaleTrait;
use Http\Client\HttpClient;
use Http\Message\MessageFactory;
use Ivory\GoogleMap\Base\Bound;
use Ivory\GoogleMap\Base\Coordinate;
use Ivory\GoogleMap\Service\AbstractService;

/**
 * @author GeLo <<EMAIL>>
 */
class GeocoderProvider extends AbstractService implements LocaleAwareProvider
{
    use LocaleTrait;

    /**
     * @var int|null
     */
    private $limit;

    /**
     * @param HttpClient     $client
     * @param MessageFactory $messageFactory
     */
    public function __construct(HttpClient $client, MessageFactory $messageFactory)
    {
        parent::__construct($client, $messageFactory, 'http://maps.googleapis.com/maps/api/geocode');
    }

    /**
     * {@inheritdoc}
     */
    public function getLimit()
    {
        return $this->limit;
    }

    /**
     * {@inheritdoc}
     */
    public function limit($limit)
    {
        $this->limit = $limit;

        return $this;
    }

    /**
     * {@inheritdoc}
     */
    public function geocode($request)
    {
        if (!$request instanceof GeocoderRequest) {
            $request = new GeocoderRequest($request);
        }

        if ($this->locale !== null && !$request->hasLanguage()) {
            $request->setLanguage($this->locale);
        }

        $response = $this->getClient()->sendRequest($this->createRequest($request->buildQuery()));
        $data = $this->parse((string) $response->getBody());

        return $this->buildResponse($data);
    }

    /**
     * {@inheritdoc}
     */
    public function reverse($latitude, $longitude)
    {
        return $this->geocode(new Coordinate($latitude, $longitude));
    }

    /**
     * {@inheritdoc}
     */
    public function getName()
    {
        return 'ivory_google_map';
    }

    /**
     * @param string $data
     *
     * @return mixed[]<commit_msg>[Geocoder] Fix PHPDoc<commit_after><?php

/*
 * This file is part of the Ivory Google Map package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please read the LICENSE
 * file that was distributed with this source code.
 */

namespace Ivory\GoogleMap\Service\Geocoder;

use Geocoder\Provider\LocaleAwareProvider;
use Geocoder\Provider\LocaleTrait;
use Http\Client\HttpClient;
use Http\Message\MessageFactory;
use Ivory\GoogleMap\Base\Bound;
use Ivory\GoogleMap\Base\Coordinate;
use Ivory\GoogleMap\Service\AbstractService;

/**
 * @author GeLo <<EMAIL>>
 */
class GeocoderProvider extends AbstractService implements LocaleAwareProvider
{
    use LocaleTrait;

    /**
     * @var int|null
     */
    private $limit;

    /**
     * @param HttpClient     $client
     * @param MessageFactory $messageFactory
     */
    public function __construct(HttpClient $client, MessageFactory $messageFactory)
    {
        parent::__construct($client, $messageFactory, 'http://maps.googleapis.com/maps/api/geocode');
    }

    /**
     * {@inheritdoc}
     */
    public function getLimit()
    {
        return $this->limit;
    }

    /**
     * {@inheritdoc}
     */
    public function limit($limit)
    {
        $this->limit = $limit;

        return $this;
    }

    /**
     * @param GeocoderRequest|string $request
     *
     * @return GeocoderResponse
     */
    public function geocode($request)
    {
        if (!$request instanceof GeocoderRequest) {
            $request = new GeocoderRequest($request);
        }

        if ($this->locale !== null && !$request->hasLanguage()) {
            $request->setLanguage($this->locale);
        }

        $response = $this->getClient()->sendRequest($this->createRequest($request->buildQuery()));
        $data = $this->parse((string) $response->getBody());

        return $this->buildResponse($data);
    }

    /**
     * @param float $latitude
     * @param float $longitude
     *
     * @return GeocoderResponse
     */
    public function reverse($latitude, $longitude)
    {
        return $this->geocode(new Coordinate($latitude, $longitude));
    }

    /**
     * {@inheritdoc}
     */
    public function getName()
    {
        return 'ivory_google_map';
    }

    /**
     * @param string $data
     *
     * @return mixed[]
{'fraction_non_alphanumeric': 0.1371200355003328, 'fraction_numerical': 0.0, 'mean_word_length': 2.5329153605015673, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3508060', 'n_tokens_mistral': 1350, 'n_tokens_neox': 1326, 'n_words': 284}