| Conditions | 4 | 
| Paths | 2 | 
| Total Lines | 21 | 
| Code Lines | 13 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Tests | 0 | 
| CRAP Score | 20 | 
| Changes | 0 | ||
| 1 | <?php | ||
| 28 | public function getUsersByParams($params) | ||
| 29 |     { | ||
| 30 | $em = $this->getEntityManager(); | ||
| 31 | |||
| 32 | $postsQuery = $em->createQueryBuilder() | ||
| 33 |             ->select('u') | ||
| 34 |             ->from('AppBundle:User', 'u') | ||
| 35 |             ->orderBy('u.createdAt',  preg_match('/asc/i', $params->get('order')) ? 'ASC' : 'DESC'); | ||
| 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 |