updrade with rector
This commit is contained in:
@@ -4,8 +4,6 @@ namespace App\Repository;
|
||||
|
||||
use App\Entity\Quotes;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\ORM\OptimisticLockException;
|
||||
use Doctrine\ORM\ORMException;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
@@ -21,8 +19,6 @@ class QuotesRepository extends ServiceEntityRepository
|
||||
parent::__construct(registry: $registry, entityClass: Quotes::class);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function add(Quotes $entity, bool $flush = true): void
|
||||
{
|
||||
$this->_em->persist($entity);
|
||||
@@ -31,8 +27,6 @@ class QuotesRepository extends ServiceEntityRepository
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function remove(Quotes $entity, bool $flush = true): void
|
||||
{
|
||||
$this->_em->remove($entity);
|
||||
@@ -40,29 +34,28 @@ class QuotesRepository extends ServiceEntityRepository
|
||||
$this->_em->flush();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return null|float|int|mixed|string
|
||||
* @throws \Doctrine\ORM\NonUniqueResultException
|
||||
*/
|
||||
public function findOneRandom(): mixed
|
||||
{
|
||||
$idLimits = $this->createQueryBuilder(alias: 'q')
|
||||
->select('MIN(q.id)', 'MAX(q.id)')
|
||||
->getQuery()
|
||||
->getOneOrNullResult();
|
||||
$randomPossibleId = rand(min: $idLimits[1], max: $idLimits[2]);
|
||||
|
||||
return $this->createQueryBuilder(alias: 'q')
|
||||
->where(predicates: 'q.id >= :random_id')
|
||||
->setParameter(key: 'random_id', value: $randomPossibleId)
|
||||
->setMaxResults(maxResults: 1)
|
||||
->getQuery()
|
||||
->getOneOrNullResult();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return float|int|mixed|string|null
|
||||
*
|
||||
* @throws \Doctrine\ORM\NonUniqueResultException
|
||||
*/
|
||||
public function findOneRandom(): mixed
|
||||
{
|
||||
$idLimits = $this->createQueryBuilder(alias: 'q')
|
||||
->select('MIN(q.id)', 'MAX(q.id)')
|
||||
->getQuery()
|
||||
->getOneOrNullResult();
|
||||
$randomPossibleId = rand(min: $idLimits[1], max: $idLimits[2]);
|
||||
|
||||
return $this->createQueryBuilder(alias: 'q')
|
||||
->where(predicates: 'q.id >= :random_id')
|
||||
->setParameter(key: 'random_id', value: $randomPossibleId)
|
||||
->setMaxResults(maxResults: 1)
|
||||
->getQuery()
|
||||
->getOneOrNullResult();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return Quotes[] Returns an array of Quotes objects
|
||||
// */
|
||||
|
Reference in New Issue
Block a user