<commit_before><?php

namespace OpenOrchestra\BaseApiBundle\Repository;

use Doctrine\ODM\MongoDB\DocumentRepository;
use OpenOrchestra\BaseApi\Model\ApiClientInterface;

/**
 * Class ApiClientRepository
 */
class ApiClientRepository extends DocumentRepository
{
    /**
     * @param string $key
     * @param string $secret
     *
     * @return ApiClientInterface
     */
    public function findOneByKeyAndSecret($key, $secret)
    {
        return $this->findOneBy(array('key' => $key, 'secret' => $secret));
    }

    /**
     * @param array|null  $descriptionEntity
     * @param array|null  $columns
     * @param string|null $search
     * @param array|null  $order
     * @param int|null    $skip
     * @param int|null    $limit
     *
     * @return array
     */
    public function findForPaginateAndSearch($descriptionEntity = null, $columns = null, $search = null, $order = null, $skip = null, $limit = null)
    {
        $qb = $this->createQueryWithSearchAndOrderFilter($descriptionEntity, $columns, $search, $order);

        if (null !== $skip && $skip > 0) {
            $qb->skip($skip);
        }

        if (null !== $limit) {
            $qb->limit($limit);
        }

        return $qb->getQuery()->execute();
    }

    /**
     * @return int
     */
    public function count()
    {
        $qb = $this->createQueryBuilder();

        return $qb->count()->getQuery()->execute();
    }

    /**
     * @param array|null $columns
     * @param array|null $descriptionEntity
     * @param array|null $search
     *
     * @return int
     */
    public function countFilterSearch($descriptionEntity = null, $columns = null, $search = null)
    {
        $qb = $this->createQueryWithSearchFilter($descriptionEntity, $columns, $search);

        return $qb->count()->getQuery()->execute();
    }

    /**
     * @param string $value
     * @param string $type
     *
     * @return mixed
     */
    protected function getFilterSearchField($value, $type)
    {
        if ($type == 'integer') {
            $filter = (int) $value;
        } elseif ($type == 'boolean') {
            $value = ($value === 'true' || $value === '1') ? true : false;
            $filter = $value;
        } else {
            $filter = new \MongoRegex('/.*'.$value.'.*/i');
        }<commit_msg>rename method countFilterSearch by countWithSearchFilter<commit_after><?php

namespace OpenOrchestra\BaseApiBundle\Repository;

use Doctrine\ODM\MongoDB\DocumentRepository;
use OpenOrchestra\BaseApi\Model\ApiClientInterface;

/**
 * Class ApiClientRepository
 */
class ApiClientRepository extends DocumentRepository
{
    /**
     * @param string $key
     * @param string $secret
     *
     * @return ApiClientInterface
     */
    public function findOneByKeyAndSecret($key, $secret)
    {
        return $this->findOneBy(array('key' => $key, 'secret' => $secret));
    }

    /**
     * @param array|null  $descriptionEntity
     * @param array|null  $columns
     * @param string|null $search
     * @param array|null  $order
     * @param int|null    $skip
     * @param int|null    $limit
     *
     * @return array
     */
    public function findForPaginateAndSearch($descriptionEntity = null, $columns = null, $search = null, $order = null, $skip = null, $limit = null)
    {
        $qb = $this->createQueryWithSearchAndOrderFilter($descriptionEntity, $columns, $search, $order);

        if (null !== $skip && $skip > 0) {
            $qb->skip($skip);
        }

        if (null !== $limit) {
            $qb->limit($limit);
        }

        return $qb->getQuery()->execute();
    }

    /**
     * @return int
     */
    public function count()
    {
        $qb = $this->createQueryBuilder();

        return $qb->count()->getQuery()->execute();
    }

    /**
     * @param array|null $columns
     * @param array|null $descriptionEntity
     * @param array|null $search
     *
     * @return int
     */
    public function countWithSearchFilter($descriptionEntity = null, $columns = null, $search = null)
    {
        $qb = $this->createQueryWithSearchFilter($descriptionEntity, $columns, $search);

        return $qb->count()->getQuery()->execute();
    }

    /**
     * @param string $value
     * @param string $type
     *
     * @return mixed
     */
    protected function getFilterSearchField($value, $type)
    {
        if ($type == 'integer') {
            $filter = (int) $value;
        } elseif ($type == 'boolean') {
            $value = ($value === 'true' || $value === '1') ? true : false;
            $filter = $value;
        } else {
            $filter = new \MongoRegex('/.*'.$value.'.*/i');
        }
{'fraction_non_alphanumeric': 0.15358141535814154, 'fraction_numerical': 0.0008604000860400087, 'mean_word_length': 2.3143264433357094, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 37, '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': '2551685', 'n_tokens_mistral': 1383, 'n_tokens_neox': 1380, 'n_words': 302}