<commit_before><?php

/**
 * This file belongs to Kreta.
 * The source code of application includes a LICENSE file
 * with all information about license.
 *
 * @author benatespina <<EMAIL>>
 * @author gorkalaucirica <<EMAIL>>
 */

namespace Kreta\Bundle\CommentBundle\Behat;

use Behat\Gherkin\Node\TableNode;
use Kreta\Bundle\CoreBundle\Behat\DefaultContext;

/**
 * Class CommentContext.
 *
 * @package Kreta\Bundle\CommentBundle\Behat
 */
class CommentContext extends DefaultContext
{
    /**
     * Populates the database with comments.
     *
     * @param \Behat\Gherkin\Node\TableNode $comments The comments
     *
     * @return void
     *
     * @Given /^the following comments exist:$/
     */
    public function theFollowingCommentsExist(TableNode $comments)
    {
        foreach ($comments as $commentData) {
            $issue = $this->container->get('kreta_issue.repository.issue')
                ->findOneBy(['title' => $commentData['issue']], false);
            $user = $this->container->get('kreta_user.repository.user')
                ->findOneBy(['email' => $commentData['user']], false);

            $comment = $this->container->get('kreta_comment.factory.comment')->create($issue, $user);
            $comment->setDescription($commentData['description']);
            if (isset($commentData['updatedAt'])) {
                $this->setField($comment, 'updatedAt', new \DateTime($commentData['updatedAt']));
            }
            if (isset($commentData['createdAt'])) {
                $this->setField($comment, 'createdAt', new \DateTime($commentData['createdAt']));
            }
            if (isset($commentData['id'])) {
                $this->setId($comment, $commentData['id']);
            }

            $this->container->get('kreta_comment.repository.comment')->persist($comment);
        }
    }
}
<commit_msg>Refactored DefaultContext<commit_after><?php

/**
 * This file belongs to Kreta.
 * The source code of application includes a LICENSE file
 * with all information about license.
 *
 * @author benatespina <<EMAIL>>
 * @author gorkalaucirica <<EMAIL>>
 */

namespace Kreta\Bundle\CommentBundle\Behat;

use Behat\Gherkin\Node\TableNode;
use Kreta\Bundle\CoreBundle\Behat\DefaultContext;

/**
 * Class CommentContext.
 *
 * @package Kreta\Bundle\CommentBundle\Behat
 */
class CommentContext extends DefaultContext
{
    /**
     * Populates the database with comments.
     *
     * @param \Behat\Gherkin\Node\TableNode $comments The comments
     *
     * @return void
     *
     * @Given /^the following comments exist:$/
     */
    public function theFollowingCommentsExist(TableNode $comments)
    {
        foreach ($comments as $commentData) {
            $issue = $this->get('kreta_issue.repository.issue')->findOneBy(['title' => $commentData['issue']], false);
            $user = $this->get('kreta_user.repository.user')->findOneBy(['email' => $commentData['user']], false);

            $comment = $this->get('kreta_comment.factory.comment')->create($issue, $user);
            $comment->setDescription($commentData['description']);
            if (isset($commentData['updatedAt'])) {
                $this->setField($comment, 'updatedAt', new \DateTime($commentData['updatedAt']));
            }
            if (isset($commentData['createdAt'])) {
                $this->setField($comment, 'createdAt', new \DateTime($commentData['createdAt']));
            }
            if (isset($commentData['id'])) {
                $this->setId($comment, $commentData['id']);
            }

            $this->get('kreta_comment.repository.comment')->persist($comment);
        }
    }
}

{'fraction_non_alphanumeric': 0.15503023639362287, 'fraction_numerical': 0.0, 'mean_word_length': 2.846723044397463, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 43, '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': '7426255', 'n_tokens_mistral': 1033, 'n_tokens_neox': 1022, 'n_words': 191}