<commit_before><?php

/*
 * This file is part of the Kreta package.
 *
 * (c) <NAME> <<EMAIL>>
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Kreta\Component\Workflow\Repository;

use Kreta\Component\Core\Repository\EntityRepository;
use Kreta\Component\Workflow\Model\Interfaces\StatusInterface;
use Kreta\Component\Workflow\Model\Interfaces\WorkflowInterface;

/**
 * Class StatusRepository.
 *
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 */
class StatusRepository extends EntityRepository
{
    /**
     * Finds the status of ids given.
     *
     * @param mixed                                                        $ids      A collection of ids, can be an
     *                                                                               simple string with comma separated
     *                                                                               or an array
     * @param \Kreta\Component\Workflow\Model\Interfaces\WorkflowInterface $workflow The workflow
     *
     * @return \Kreta\Component\Workflow\Model\Interfaces\StatusInterface[]
     */
    public function findByIds($ids, WorkflowInterface $workflow)
    {
        if (!(is_array($ids))) {
            $ids = explode(',', str_replace(' ', '', $ids));
        }

        $queryBuilder = $this->getQueryBuilder();
        $this->addCriteria($queryBuilder, ['workflow' => $workflow]);
        $queryBuilder->andWhere($queryBuilder->expr()->eq('s.id', ':id'));

        $result = [];
        foreach ($ids as $id) {
            $status = $queryBuilder
                ->setParameter('id', $id)
                ->getQuery()->getOneOrNullResult();

            if ($status instanceof StatusInterface) {
                $result[] = $status;
            }
        }

        return array_unique($result, SORT_REGULAR);
    }

    /**
     * {@inheritdoc}
     */<commit_msg>Fixed a minor bug related with PHP and HHVM versions<commit_after><?php

/*
 * This file is part of the Kreta package.
 *
 * (c) <NAME> <<EMAIL>>
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Kreta\Component\Workflow\Repository;

use Kreta\Component\Core\Repository\EntityRepository;
use Kreta\Component\Workflow\Model\Interfaces\StatusInterface;
use Kreta\Component\Workflow\Model\Interfaces\WorkflowInterface;

/**
 * Class StatusRepository.
 *
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 */
class StatusRepository extends EntityRepository
{
    /**
     * Finds the status of ids given.
     *
     * @param mixed                                                        $ids      A collection of ids, can be an
     *                                                                               simple string with comma separated
     *                                                                               or an array
     * @param \Kreta\Component\Workflow\Model\Interfaces\WorkflowInterface $workflow The workflow
     *
     * @return \Kreta\Component\Workflow\Model\Interfaces\StatusInterface[]
     */
    public function findByIds($ids, WorkflowInterface $workflow)
    {
        if (!(is_array($ids))) {
            $ids = explode(',', str_replace(' ', '', $ids));
        }

        $queryBuilder = $this->getQueryBuilder();
        $this->addCriteria($queryBuilder, ['workflow' => $workflow]);
        $queryBuilder->andWhere($queryBuilder->expr()->eq('s.id', ':id'));

        $result = [];
        foreach ($ids as $id) {
            $status = $queryBuilder
                ->setParameter('id', $id)
                ->getQuery()->getOneOrNullResult();

            if ($status instanceof StatusInterface) {
                $result[] = $status;
            }
        }

        return defined('HHVM_VERSION')
            ? array_unique($result, SORT_REGULAR)
            : array_unique($result);
    }

    /**
     * {@inheritdoc}
     */
{'fraction_non_alphanumeric': 0.12521440823327615, 'fraction_numerical': 0.0, 'mean_word_length': 1.8426183844011141, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5998605', 'n_tokens_mistral': 1059, 'n_tokens_neox': 1039, 'n_words': 257}