<commit_before><?php
/*
 * This file is part of the WB\ElasticaBundle package.
 *
 * (c) WikiBusiness <http://company.wikibusiness.org/>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace WB\GisgraphyBundle\Client;

use GuzzleHttp\Client;

/**
 * Class Gisgsraphy
 *
 * @package WB\GisgraphyBundle\Client
 * @author  <NAME> <<EMAIL>>
 */
class Gisgsraphy
{

    /**
     * @var Client
     */
    private $client;

    /**
     * @var array
     */
    private $default_options = [
        'indent' => true,
        'format' => 'json',
    ];

    private $address;

    /**
     * @var string
     */
    private $country;

    /**
     * @var string
     */
    private $endpoint = 'http://services.gisgraphy.com/addressparser';

    public function __construct()
    {
        $this->client = new Client();
    }

    /**
     * @param $address
     */
    public function setAddress($address)
    {
        $this->address = str_replace(',', ' ', $address);

    }

    /**
     * @param $country
     */
    public function setCountry($country)
    {
        $this->country = $country;
    }

    /**
     * @param array $options
     *
     * @return \GuzzleHttp\Message\FutureResponse|\GuzzleHttp\Message\ResponseInterface|\GuzzleHttp\Ring\Future\FutureInterface|null
     */
    public function parse(array $options = [])
    {
        $options = array_merge($this->default_options, $options);

        $options['country'] = $this->country;
        $options['address'] = $this->address;

        $response = $this->client->get($this->endpoint, http_build_query($options));

        return $response;
    }
}<commit_msg>Fix typo in classname. Move http requst into a try catch block.<commit_after><?php
/*
 * This file is part of the WB\ElasticaBundle package.
 *
 * (c) WikiBusiness <http://company.wikibusiness.org/>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace WB\GisgraphyBundle\Client;

use GuzzleHttp\Client;

/**
 * Class Gisgsraphy
 *
 * @package WB\GisgraphyBundle\Client
 * @author  <NAME> <<EMAIL>>
 */
class Gisgraphy
{

    /**
     * @var Client
     */
    private $client;

    /**
     * @var array
     */
    private $default_options = [
        'indent' => true,
        'format' => 'json',
    ];

    private $address;

    /**
     * @var string
     */
    private $country;

    /**
     * @var string
     */
    private $endpoint = 'http://services.gisgraphy.com/addressparser';

    public function __construct()
    {
        $this->client = new Client();
    }

    /**
     * @param $address
     *
     * @return $this
     */
    public function setAddress($address)
    {
        $this->address = str_replace(',', ' ', $address);

        return $this;
    }

    /**
     * @param $country
     *
     * @return $this
     */
    public function setCountry($country)
    {
        $this->country = $country;

        return $this;
    }

    /**
     * @param array $options
     *
     * @return \GuzzleHttp\Message\FutureResponse|\GuzzleHttp\Message\ResponseInterface|\GuzzleHttp\Ring\Future\FutureInterface|null
     */
    public function parse(array $options = [])
    {
        $options = array_merge($this->default_options, $options);

        $options['country'] = $this->country;
        $options['address'] = $this->address;

        try {
            return $this->client->get($this->endpoint.'?'.http_build_query($options));
        } catch (\Exception $e) {
            return false;
        }

    }
}
{'fraction_non_alphanumeric': 0.14657534246575343, 'fraction_numerical': 0.0, 'mean_word_length': 2.2139084507042255, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 33, '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': '2599851', 'n_tokens_mistral': 1146, 'n_tokens_neox': 1097, 'n_words': 240}