mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -16,11 +16,6 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
use Exception;
|
||||
|
||||
use function count;
|
||||
use function in_array;
|
||||
use function str_replace;
|
||||
|
||||
class PersonRepository implements ObjectRepository
|
||||
{
|
||||
@@ -32,8 +27,6 @@ class PersonRepository implements ObjectRepository
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $centers
|
||||
*
|
||||
* @throws \Doctrine\ORM\NoResultException
|
||||
* @throws \Doctrine\ORM\NonUniqueResultException
|
||||
*/
|
||||
@@ -51,7 +44,7 @@ class PersonRepository implements ObjectRepository
|
||||
return $qb->getQuery()->getSingleScalarResult();
|
||||
}
|
||||
|
||||
public function createQueryBuilder(string $alias, ?string $indexBy = null): QueryBuilder
|
||||
public function createQueryBuilder(string $alias, string $indexBy = null): QueryBuilder
|
||||
{
|
||||
return $this->repository->createQueryBuilder($alias, $indexBy);
|
||||
}
|
||||
@@ -66,7 +59,7 @@ class PersonRepository implements ObjectRepository
|
||||
return $this->repository->findAll();
|
||||
}
|
||||
|
||||
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null)
|
||||
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
@@ -77,13 +70,7 @@ class PersonRepository implements ObjectRepository
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $centers
|
||||
* @param $firstResult
|
||||
* @param $maxResults
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @return mixed
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function findByPhone(
|
||||
string $phonenumber,
|
||||
@@ -116,43 +103,40 @@ class PersonRepository implements ObjectRepository
|
||||
|
||||
private function addByCenters(QueryBuilder $qb, array $centers): void
|
||||
{
|
||||
if (count($centers) > 0) {
|
||||
if (\count($centers) > 0) {
|
||||
$qb->andWhere($qb->expr()->in('p.center', ':centers'));
|
||||
$qb->setParameter('centers', $centers);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function addPhoneNumber(QueryBuilder $qb, string $phonenumber, array $only): void
|
||||
{
|
||||
if (count($only) === 0) {
|
||||
throw new Exception('No array field to search');
|
||||
if (0 === \count($only)) {
|
||||
throw new \Exception('No array field to search');
|
||||
}
|
||||
|
||||
$phonenumber = $this->parsePhoneNumber($phonenumber);
|
||||
|
||||
$orX = $qb->expr()->orX();
|
||||
|
||||
if (in_array('mobile', $only, true)) {
|
||||
if (\in_array('mobile', $only, true)) {
|
||||
$orX->add($qb->expr()->like("REPLACE(p.mobilenumber, ' ', '')", ':phonenumber'));
|
||||
}
|
||||
|
||||
if (in_array('phone', $only, true)) {
|
||||
if (\in_array('phone', $only, true)) {
|
||||
$orX->add($qb->expr()->like("REPLACE(p.phonenumber, ' ', '')", ':phonenumber'));
|
||||
}
|
||||
|
||||
$qb->andWhere($orX);
|
||||
|
||||
$qb->setParameter('phonenumber', '%' . $phonenumber . '%');
|
||||
$qb->setParameter('phonenumber', '%'.$phonenumber.'%');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $phonenumber
|
||||
*/
|
||||
private function parsePhoneNumber(string $phonenumber): string
|
||||
{
|
||||
return str_replace(' ', '', $phonenumber);
|
||||
return \str_replace(' ', '', $phonenumber);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user