<commit_before><?php
namespace AppVentus\MangopayBundle\Helper;

use AppVentus\MangopayBundle\AppVentusMangopayEvents;
use AppVentus\MangopayBundle\Entity\UserInterface;
use AppVentus\MangopayBundle\Event\WalletEvent;
use MangoPay\Wallet;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

/**
 *
 * ref: appventus_mangopay.wallet_helper
 *
 **/
class WalletHelper
{
    private $mangopayHelper;
    private $dispatcher;

    public function __construct(MangopayHelper $mangopayHelper, EventDispatcherInterface $dispatcher)
    {
        $this->mangopayHelper = $mangopayHelper;
        $this->dispatcher = $dispatcher;
    }

    public function findOrCreateWallet(UserInterface $user, $description = '')
    {

        if ($wallet = $user->getWallet()) {
            $wallet = $this->mangopayHelper->Wallets->get($wallet->getMangoId());
        // else, create a new mango user
        } else {
            $wallet = $this->createWalletForUser($user, $description);
        }

        return $user->getWallet();
    }

    public function createWalletForUser(UserInterface $user, $description = '')
    {
        $mangoWallet = new Wallet();
        $mangoWallet->Owners = array($user->getMangoUserId());
        $mangoWallet->Currency = "EUR";
        $mangoWallet->Description = $description;

        $mangoWallet = $this->mangopayHelper->Wallets->create($mangoWallet);

        $event = new WalletEvent($mangoWallet, $user);
        $this->dispatcher->dispatch(AppVentusMangopayEvents::NEW_WALLET, $event);

        return $mangoWallet;
    }

}
<commit_msg>empty description are not allowed<commit_after><?php
namespace AppVentus\MangopayBundle\Helper;

use AppVentus\MangopayBundle\AppVentusMangopayEvents;
use AppVentus\MangopayBundle\Entity\UserInterface;
use AppVentus\MangopayBundle\Event\WalletEvent;
use MangoPay\Wallet;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

/**
 *
 * ref: appventus_mangopay.wallet_helper
 *
 **/
class WalletHelper
{
    private $mangopayHelper;
    private $dispatcher;

    public function __construct(MangopayHelper $mangopayHelper, EventDispatcherInterface $dispatcher)
    {
        $this->mangopayHelper = $mangopayHelper;
        $this->dispatcher = $dispatcher;
    }

    public function findOrCreateWallet(UserInterface $user, $description = 'current wallet')
    {

        if ($wallet = $user->getWallet()) {
            $wallet = $this->mangopayHelper->Wallets->get($wallet->getMangoId());
        // else, create a new mango user
        } else {
            $wallet = $this->createWalletForUser($user, $description);
        }

        return $user->getWallet();
    }

    public function createWalletForUser(UserInterface $user, $description = 'current wallet')
    {
        $mangoWallet = new Wallet();
        $mangoWallet->Owners = array($user->getMangoUserId());
        $mangoWallet->Currency = "EUR";
        $mangoWallet->Description = $description;

        $mangoWallet = $this->mangopayHelper->Wallets->create($mangoWallet);

        $event = new WalletEvent($mangoWallet, $user);
        $this->dispatcher->dispatch(AppVentusMangopayEvents::NEW_WALLET, $event);

        return $mangoWallet;
    }

}

{'fraction_non_alphanumeric': 0.12234706616729088, 'fraction_numerical': 0.0, 'mean_word_length': 3.5332390381895333, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 39, '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': '1168345', 'n_tokens_mistral': 1011, 'n_tokens_neox': 1034, 'n_words': 162}