<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\TimeTrackingBundle\Behat;

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

/**
 * Class TimeEntryContext.
 *
 * @package Kreta\Bundle\TimeTrackingBundle\Behat
 */
class TimeEntryContext extends DefaultContext
{
    /**
     * Populates the database with time entries.
     *
     * @param \Behat\Gherkin\Node\TableNode $timeEntries The time entries
     *
     * @return void
     *
     * @Given /^the following time entries exist:$/
     */
    public function theFollowingTimeEntriesExist(TableNode $timeEntries)
    {
        foreach ($timeEntries as $timeEntryData) {
            $issue = $this->getContainer()->get('kreta_issue.repository.issue')
                ->findOneBy(['title' => $timeEntryData['issue']]);

            $timeEntry = $this->getContainer()->get('kreta_time_tracking.factory.time_entry')->create($issue);
            $timeEntry->setDescription($timeEntryData['description']);
            $timeEntry->setTimeSpent($timeEntryData['timeSpent']);
            if (isset($timeEntryData['dateReported'])) {
                $this->setField($timeEntry, 'dateReported', new \DateTime($timeEntryData['dateReported']));
            }
            if (isset($timeEntryData['id'])) {
                $this->setId($timeEntry, $timeEntryData['id']);
            }

            $this->getContainer()->get('kreta_time_tracking.repository.time_entry')->persist($timeEntry);
        }
    }
}<commit_msg>Refactored Behat contexts and reorganized the scenarios<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\TimeTrackingBundle\Behat;

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

/**
 * Class TimeEntryContext.
 *
 * @package Kreta\Bundle\TimeTrackingBundle\Behat
 */
class TimeEntryContext extends DefaultContext
{
    /**
     * Populates the database with time entries.
     *
     * @param \Behat\Gherkin\Node\TableNode $timeEntries The time entries
     *
     * @return void
     *
     * @Given /^the following time entries exist:$/
     */
    public function theFollowingTimeEntriesExist(TableNode $timeEntries)
    {
        foreach ($timeEntries as $timeEntryData) {
            $issue = $this->container->get('kreta_issue.repository.issue')
                ->findOneBy(['title' => $timeEntryData['issue']], false);

            $timeEntry = $this->container->get('kreta_time_tracking.factory.time_entry')->create($issue);
            $timeEntry
                ->setDescription($timeEntryData['description'])
                ->setTimeSpent($timeEntryData['timeSpent']);
            if (isset($timeEntryData['dateReported'])) {
                $this->setField($timeEntry, 'dateReported', new \DateTime($timeEntryData['dateReported']));
            }
            if (isset($timeEntryData['id'])) {
                $this->setId($timeEntry, $timeEntryData['id']);
            }

            $this->container->get('kreta_time_tracking.repository.time_entry')->persist($timeEntry);
        }
    }
}
{'fraction_non_alphanumeric': 0.13726059199071386, 'fraction_numerical': 0.0, 'mean_word_length': 3.0128055878928985, 'pattern_counts': {'":': 0, '<': 13, '<?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': '2980466', 'n_tokens_mistral': 997, 'n_tokens_neox': 979, 'n_words': 182}