<commit_before><?php
/**
 * Created by <NAME> (<EMAIL>)
 * Company: PartFire Ltd (www.partfire.co.uk)
 * Copyright © 2016 PartFire Ltd. All rights reserved.
 *
 * User:    <NAME>
 * Date:    27/11/2016
 * Time:    21:11
 * File:    UserQuery.php
 **/

namespace PartFire\MangoPayBundle\Models\Adapters;

use MangoPay\Libraries\Exception;
use MangoPay\Libraries\ResponseException;
use MangoPay\MangoPayApi;
use PartFire\MangoPayBundle\Models\DTOs\Translators\UserTranslator;
use PartFire\MangoPayBundle\Models\DTOs\User;
use PartFire\MangoPayBundle\Models\Exception as PartFireException;
use PartFire\MangoPayBundle\Models\UserQueryInterface;
use Symfony\Bridge\Monolog\Logger;

class UserQuery extends AbstractQuery implements UserQueryInterface
{
    /**
     * @var UserTranslator
     */
    protected $userTranslator;

    public function __construct(
        $clientId,
        $clientPassword,
        $baseUrl,
        MangoPayApi $mangoPayApi,
        Logger $logger,
        UserTranslator $userTranslator
    ) {
        parent::__construct($clientId, $clientPassword, $baseUrl,$mangoPayApi, $logger);
        $this->userTranslator = $userTranslator;
    }

    /**
     * @param User $userDto
     * @return User|PartFireException
     */
    public function create(User $userDto)
    {
        $mangoUser = $this->userTranslator->convertDTOToMangoPayNaturalUser($userDto);
        try {
            $mangoUser = $this->mangoPayApi->Users->Create($mangoUser);
        } catch (ResponseException $e) {
            $this->logger->addCritical($e->getMessage(), ['code' => $e->getCode(), 'details' => $e->GetErrorDetails()]);
            return new PartFireException($e->getMessage(), $e->getCode());
        } catch (Exception $e) {
            $this->logger->addError($e->getMessage());
            return new PartFireException($e->getMessage(), $e->getCode());
        }
        return $this->userTranslator->convertMangoPayNaturalUserToDTO($mangoUser);
    }

    public function get($userId)
    {
        // TODO: Implement get() method.
    }

    public function getAll()
    {
        // TODO: Implement getAll() method.
    }

    public function update(User $userDto)
    {
        // TODO: Implement update() method.
    }

    public function delete($userId)
    {
        // TODO: Implement delete() method.
    }
}<commit_msg>Fixing throwing errors, not returning<commit_after><?php
/**
 * Created by <NAME> (<EMAIL>)
 * Company: PartFire Ltd (www.partfire.co.uk)
 * Copyright © 2016 PartFire Ltd. All rights reserved.
 *
 * User:    <NAME>
 * Date:    27/11/2016
 * Time:    21:11
 * File:    UserQuery.php
 **/

namespace PartFire\MangoPayBundle\Models\Adapters;

use MangoPay\Libraries\Exception;
use MangoPay\Libraries\ResponseException;
use MangoPay\MangoPayApi;
use PartFire\MangoPayBundle\Models\DTOs\Translators\UserTranslator;
use PartFire\MangoPayBundle\Models\DTOs\User;
use PartFire\MangoPayBundle\Models\Exception as PartFireException;
use PartFire\MangoPayBundle\Models\UserQueryInterface;
use Symfony\Bridge\Monolog\Logger;

class UserQuery extends AbstractQuery implements UserQueryInterface
{
    /**
     * @var UserTranslator
     */
    protected $userTranslator;

    public function __construct(
        $clientId,
        $clientPassword,
        $baseUrl,
        MangoPayApi $mangoPayApi,
        Logger $logger,
        UserTranslator $userTranslator
    ) {
        parent::__construct($clientId, $clientPassword, $baseUrl,$mangoPayApi, $logger);
        $this->userTranslator = $userTranslator;
    }

    /**
     * @param User $userDto
     * @return User|PartFireException
     */
    public function create(User $userDto)
    {
        $mangoUser = $this->userTranslator->convertDTOToMangoPayNaturalUser($userDto);
        try {
            $mangoUser = $this->mangoPayApi->Users->Create($mangoUser);
        } catch (ResponseException $e) {
            $this->logger->addCritical($e->getMessage(), ['code' => $e->getCode(), 'details' => $e->GetErrorDetails()]);
            throw new PartFireException($e->getMessage(), $e->getCode(), $e);
        } catch (Exception $e) {
            $this->logger->addError($e->getMessage());
            throw new PartFireException($e->getMessage(), $e->getCode(), $e);
        }
        return $this->userTranslator->convertMangoPayNaturalUserToDTO($mangoUser);
    }

    public function get($userId)
    {
        // TODO: Implement get() method.
    }

    public function getAll()
    {
        // TODO: Implement getAll() method.
    }

    public function update(User $userDto)
    {
        // TODO: Implement update() method.
    }

    public function delete($userId)
    {
        // TODO: Implement delete() method.
    }
}
{'fraction_non_alphanumeric': 0.130131189166314, 'fraction_numerical': 0.006771053745239103, 'mean_word_length': 2.9228215767634853, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 53, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3718098', 'n_tokens_mistral': 1469, 'n_tokens_neox': 1453, 'n_words': 282}