<commit_before><?php
namespace AppBundle\Repository;

use Doctrine\ORM\EntityRepository;
use AppBundle\Entity\User;

class UserRepository extends EntityRepository
{

  public function verifyKey($key)
  {

    $em = $this->getEntityManager();

    $query = $em
      ->createQuery('SELECT u FROM AppBundle:User u WHERE u.userkey = :key ')
      ->setParameter('key', $key);

    if(empty($query->getResult()))
      return false;
    else
      return $query->getResult();

  }

  public function generateToken()
  {

    $characters = '<KEY>';
    $token = array();
    $charactersLength = strlen($characters) - 1;

    for ($i = 0; $i < 10; $i++)
    {

      $n = rand(0, $charactersLength);
      $token[] = $characters[$n];

    }

    return implode($token);

  }

  public function newUser($token, $mail)
  {

    $em = $this->getEntityManager();

    $query = $em
      ->createQuery('SELECT u FROM AppBundle:User u WHERE u.mail = :mail')
      ->setParameter('mail', $mail);

    if(empty($query->getResult()))
      return $this->insertNewUser($token, $mail);
    else
      return array('status' => 'user already registered');

  }

  public function insertNewUser($token, $mail)
  {

    $user = new User();
    $user->setMail($mail);
    $user->setUserkey($token);
    $user->setRights(0);

    $em = $this->getEntityManager();

    $em->persist($user);
    $em->flush();

    $this->registrationMail($token, $mail);

    return array("status" => 'User saved');

  }

  public function registerNewUser($mail)
  {

    return $this->newUser($this->generateToken(), $mail);

  }

  public function registrationMail($token, $mail)
  {

    mail($mail, 'StudentCheck Api access', 'Your api token : ', 'From: <EMAIL>');

  }

}<commit_msg>nettoyage repository user<commit_after><?php
namespace AppBundle\Repository;

use Doctrine\ORM\EntityRepository;
use AppBundle\Entity\User;

class UserRepository extends EntityRepository
{

  public function verifyKey($key)
  {

    $em = $this->getEntityManager();

    $query = $em
      ->createQuery('SELECT u FROM AppBundle:User u WHERE u.userkey = :key ')
      ->setParameter('key', $key);

    if(empty($query->getResult()))
      return false;
    else
      return $query->getResult();

  }

  public function generateToken()
  {

    $characters = '<KEY>';
    $token = array();
    $charactersLength = strlen($characters) - 1;

    for ($i = 0; $i < 10; $i++)
    {

      $n = rand(0, $charactersLength);
      $token[] = $characters[$n];

    }

    return implode($token);

  }

  public function newUser($token, $mail)
  {

    $em = $this->getEntityManager();

    $query = $em
      ->createQuery('SELECT u FROM AppBundle:User u WHERE u.mail = :mail')
      ->setParameter('mail', $mail);

    if(empty($query->getResult()))
      return $this->insertNewUser($token, $mail);
    else
      return array('status' => 'user already registered');

  }

  public function insertNewUser($token, $mail)
  {

    $user = new User();
    $user->setMail($mail);
    $user->setUserkey($token);
    $user->setRights(0);

    $em = $this->getEntityManager();

    $em->persist($user);
    $em->flush();

    $this->registrationMail($token, $mail);

    return array("status" => 'User saved');

  }

  public function registerNewUser($mail)
  {

    return $this->newUser($this->generateToken(), $mail);

  }

}
{'fraction_non_alphanumeric': 0.1707825052067837, 'fraction_numerical': 0.0035703659625111574, 'mean_word_length': 3.13530135301353, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 48, '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': '4322209', 'n_tokens_mistral': 1123, 'n_tokens_neox': 1056, 'n_words': 237}