<commit_before><?php

namespace Progeny\Service;

use Zend\Db\TableGateway\TableGateway;
use Progeny\Entity\Progeny;
use Zend\Db\ResultSet\ResultSet;
use Zend\Db\Sql\Select;

class ProgenyTable
{
 /** @var \Doctrine\ORM\EntityManager $progenyTable */
 protected $em;

 /** @var  \Facebook $facebook */
 protected $facebook;

 protected $fb_id;

 /** @var \Zend\ServiceManager\ServiceManager $sm */
 protected $sm;

 public function __construct(\Zend\ServiceManager\ServiceManager $sm)
 {
  $this->sm = $sm;
  $this->em = $this->sm->get('Doctrine\ORM\EntityManager');
 }

 public function removeProgeny($progeny)
 {
  $this->em->remove($progeny);
  $this->em->flush();
 }

 public function checkFirstNameUnique($first_name)
 {
  $qb = $this->em->createQueryBuilder();

  /** @var \User\Entity\User $user */
  $user = $this->sm->get('User\Service\User');

//  $result = $qb->select('p')->from('Progeny\Entity\Progeny', 'p')
//    ->where('p.user = :user AND p.first_name = :first_name')
//    ->setParameter('user', $user)
//    ->setParameter('first_name', $first_name)
//    ->getQuery()
//    ->getResult();

  $result = $this->em->getRepository('Progeny\Entity\Progeny')->findOneBy(array('user' => $user, 'first_name' => $first_name));

  return !$result;
 }

 public function newProgeny($data)
 {
  $progeny = new Progeny();

  $progeny->exchangeArray($data);
  $progeny->setUser($this->sm->get('User\Service\User'));

  $this->em->persist($progeny);
  $this->em->flush();

  return $progeny;
 }

 /**
  * @param $progeny_id
  * @return \Progeny\Entity\Progeny
  */
 public function getProgeny($progeny_id)
 {
  return $this->em->getRepository('Progeny\Entity\Progeny')->findOneBy(
   array(
    'user' => $this->sm->get('User\Service\User'),
    'id' => $progeny_id
   ));
 }

 public function updateBirthDate($progeny, $birth_date)
 {
  $progeny->setBirthDate($birth_date);
  $this->em->persist($progeny);
  $this->em->flush();
 }

 /**
  * @param Progeny $progeny
  */
 public function saveProgeny(Progeny $progeny)
 {
  $this->em->persist($progeny);
 }

 /**
  * @return Progeny[]
  */
 public function fetchAll()
 {
  return $this->em->getRepository('Progeny\Entity\Progeny')->findAll();
 }


 public function getProgeniesArray()
 {
  /** @var \User\Service\User $user */
  $user = $this->sm->get('User\Service\User');

  $progenies = $this->em->getRepository('User\Entity\User')->findBy(array('user' => $user));

  $results = Array();

  foreach ($progenies as $progeny)
  {<commit_msg>updates on the progeny class<commit_after><?php

namespace Progeny\Service;

use Zend\Db\TableGateway\TableGateway;
use Progeny\Entity\Progeny;
use Zend\Db\ResultSet\ResultSet;
use Zend\Db\Sql\Select;

class ProgenyTable
{
 /** @var \Doctrine\ORM\EntityManager $progenyTable */
 protected $em;

 /** @var  \Facebook $facebook */
 protected $facebook;

 protected $fb_id;

 /** @var \Zend\ServiceManager\ServiceManager $sm */
 protected $sm;

 public function __construct(\Zend\ServiceManager\ServiceManager $sm)
 {
  $this->sm = $sm;
  $this->em = $this->sm->get('Doctrine\ORM\EntityManager');
 }

 public function removeProgeny($progeny)
 {
  $this->em->remove($progeny);
  $this->em->flush();
 }

 public function checkFirstNameUnique($first_name)
 {
  $qb = $this->em->createQueryBuilder();

  /** @var \User\Entity\User $user */
  $user = $this->sm->get('User\Service\User');

//  $result = $qb->select('p')->from('Progeny\Entity\Progeny', 'p')
//    ->where('p.user = :user AND p.first_name = :first_name')
//    ->setParameter('user', $user)
//    ->setParameter('first_name', $first_name)
//    ->getQuery()
//    ->getResult();

  $result = $this->em->getRepository('Progeny\Entity\Progeny')->findOneBy(array('user' => $user, 'first_name' => $first_name));

  return !$result;
 }

 public function newProgeny($data)
 {
  $progeny = new Progeny();

  $progeny->exchangeArray($data);
  $progeny->setUser($this->sm->get('User\Service\User'));

  $this->em->persist($progeny);
  $this->em->flush();

  return $progeny;
 }

 /**
  * @param $progeny_id
  * @return \Progeny\Entity\Progeny
  */
 public function getProgeny($progeny_id)
 {
  return $this->em->getRepository('Progeny\Entity\Progeny')->findOneBy(
   array(
    'user' => $this->sm->get('User\Service\User'),
    'id' => $progeny_id
   ));
 }

 public function updateBirthDate($progeny, $birth_date)
 {
  $progeny->setBirthDate($birth_date);
  $this->em->persist($progeny);
  $this->em->flush();
 }

 /**
  * @param Progeny $progeny
  */
 public function saveProgeny(Progeny $progeny)
 {
  $this->em->persist($progeny);
 }

 /**
  * @return Progeny[]
  */
 public function fetchAll()
 {
  return $this->em->getRepository('Progeny\Entity\Progeny')->findAll();
 }


 public function getProgeniesArray()
 {
  /** @var \User\Entity\User $user */
  $user = $this->sm->get('User\Service\User');

  $progenies = $this->em->getRepository('Progeny\Entity\Progeny')->findOneBy(array('user' => $user));

  $results = Array();

  foreach ($progenies as $progeny)
  {
{'fraction_non_alphanumeric': 0.20227408737283065, 'fraction_numerical': 0.0, 'mean_word_length': 4.059535822401615, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 113, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1785080', 'n_tokens_mistral': 1877, 'n_tokens_neox': 1822, 'n_words': 282}