Conditions | 5 |
Paths | 4 |
Total Lines | 25 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 30 |
Changes | 0 |
1 | <?php |
||
24 | public function getUsersByParams($params) |
||
25 | { |
||
26 | $em = $this->getEntityManager(); |
||
27 | |||
28 | $postsQuery = $em->createQueryBuilder() |
||
29 | ->select('u') |
||
30 | ->from('AppBundle:User', 'u'); |
||
31 | if ($params->has('date') && $params->get('date')== 'asc'){ |
||
32 | $postsQuery->orderBy('u.createdAt', 'ASC'); |
||
33 | } else { |
||
34 | $postsQuery->orderBy('u.createdAt', 'DESC'); |
||
35 | } |
||
36 | |||
37 | if ($params->has('name') && $params->get('name')) { |
||
38 | $postsQuery->where( |
||
39 | $postsQuery->expr()->like('u.firstName', ':name') |
||
40 | ) |
||
41 | ->orWhere( |
||
42 | $postsQuery->expr()->like('u.lastName', ':name') |
||
43 | ) |
||
44 | ->setParameter('name', '%' . $params->get('name') . '%'); |
||
45 | } |
||
46 | |||
47 | return $postsQuery->getQuery()->getResult(); |
||
48 | } |
||
49 | } |
||
50 |