<commit_before><?php
declare(strict_types = 1);
/**
 * /src/Repository/Traits/RepositoryMethodsTrait.php
 *
 * @author  TLe, <NAME> <<EMAIL>>
 */
namespace App\Repository\Traits;

use App\Entity\EntityInterface;
use App\Repository\BaseRepositoryInterface;
use App\Rest\RepositoryHelper;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\QueryBuilder;
use Doctrine\ORM\Tools\Pagination\Paginator;
use function array_map;

/**
 * Trait RepositoryMethodsTrait
 *
 * @package App\Repository\Traits
 * @author  TLe, <NAME> <<EMAIL>>
 *
 * @method EntityManager getEntityManager(): EntityManager
 * @method string        getEntityName(): string
 * @method array         getSearchColumns(): array
 * @method QueryBuilder  createQueryBuilder(string $alias = null, string $indexBy = null): QueryBuilder
 * @method void          processQueryBuilder(QueryBuilder $queryBuilder): void;
 */
trait RepositoryMethodsTrait
{
    /** @noinspection GenericObjectTypeUsageInspection */
    /**
     * Wrapper for default Doctrine repository find method.
     *
     * @param string   $id
     * @param int|null $lockMode
     * @param int|null $lockVersion
     *
     * @return EntityInterface|object|null
     *
     * @throws \Doctrine\ORM\TransactionRequiredException
     * @throws \Doctrine\ORM\OptimisticLockException
     * @throws \Doctrine\ORM\ORMInvalidArgumentException
     * @throws \Doctrine\ORM\ORMException
     */
    public function find(string $id, ?int $lockMode = null, ?int $lockVersion = null)
    {
        /** @noinspection PhpIncompatibleReturnTypeInspection */
        return $this->getEntityManager()
            ->find($this->getEntityName(), $id, $lockMode, $lockVersion);
    }

    /** @noinspection GenericObjectTypeUsageInspection */
    /**
     * Wrapper for default Doctrine repository findOneBy method.
     *
     * @param mixed[]      $criteria
     * @param mixed[]|null $orderBy
     *
     * @return EntityInterface|object|null
     */
    public function findOneBy(array $criteria, ?array $orderBy = null)
    {
        /** @noinspection PhpIncompatibleReturnTypeInspection */
        /** @psalm-suppress TooManyArguments */
        return $this->getEntityManager()
            ->getRepository($this->getEntityName())
            ->/** @scrutinizer ignore-call */findOneBy($criteria, $orderBy);
    }

    /**
     * Wrapper for default Doctrine repository findBy method.
     *
     * @param mixed[]      $criteria
     * @param mixed[]|null $orderBy
     * @param int|null     $limit
     * @param int|null     $offset
     *
     * @return EntityInterface[]|array<int, mixed>
     */
    public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array<commit_msg>style: Removed not needed @noinspection comments<commit_after><?php
declare(strict_types = 1);
/**
 * /src/Repository/Traits/RepositoryMethodsTrait.php
 *
 * @author  TLe, <NAME> <<EMAIL>>
 */
namespace App\Repository\Traits;

use App\Entity\EntityInterface;
use App\Repository\BaseRepositoryInterface;
use App\Rest\RepositoryHelper;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\QueryBuilder;
use Doctrine\ORM\Tools\Pagination\Paginator;
use function array_map;

/**
 * Trait RepositoryMethodsTrait
 *
 * @package App\Repository\Traits
 * @author  TLe, <NAME> <<EMAIL>>
 *
 * @method EntityManager getEntityManager(): EntityManager
 * @method string        getEntityName(): string
 * @method array         getSearchColumns(): array
 * @method QueryBuilder  createQueryBuilder(string $alias = null, string $indexBy = null): QueryBuilder
 * @method void          processQueryBuilder(QueryBuilder $queryBuilder): void;
 */
trait RepositoryMethodsTrait
{
    /**
     * Wrapper for default Doctrine repository find method.
     *
     * @param string   $id
     * @param int|null $lockMode
     * @param int|null $lockVersion
     *
     * @return EntityInterface|object|null
     *
     * @throws \Doctrine\ORM\TransactionRequiredException
     * @throws \Doctrine\ORM\OptimisticLockException
     * @throws \Doctrine\ORM\ORMInvalidArgumentException
     * @throws \Doctrine\ORM\ORMException
     */
    public function find(string $id, ?int $lockMode = null, ?int $lockVersion = null)
    {
        /** @noinspection PhpIncompatibleReturnTypeInspection */
        return $this->getEntityManager()
            ->find($this->getEntityName(), $id, $lockMode, $lockVersion);
    }

    /**
     * Wrapper for default Doctrine repository findOneBy method.
     *
     * @param mixed[]      $criteria
     * @param mixed[]|null $orderBy
     *
     * @return EntityInterface|object|null
     */
    public function findOneBy(array $criteria, ?array $orderBy = null)
    {
        /** @noinspection PhpIncompatibleReturnTypeInspection */
        /** @psalm-suppress TooManyArguments */
        return $this->getEntityManager()
            ->getRepository($this->getEntityName())
            ->/** @scrutinizer ignore-call */findOneBy($criteria, $orderBy);
    }

    /**
     * Wrapper for default Doctrine repository findBy method.
     *
     * @param mixed[]      $criteria
     * @param mixed[]|null $orderBy
     * @param int|null     $limit
     * @param int|null     $offset
     *
     * @return EntityInterface[]|array<int, mixed>
     */
    public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array
{'fraction_non_alphanumeric': 0.12117843246247915, 'fraction_numerical': 0.00037057624606262737, 'mean_word_length': 3.1651234567901234, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 31, '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': '818804', 'n_tokens_mistral': 1569, 'n_tokens_neox': 1564, 'n_words': 356}