| Conditions | 2 |
| Paths | 2 |
| Total Lines | 54 |
| Code Lines | 25 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 11 | public function customersLoginAction(Request $request) |
||
|
|
|||
| 12 | { |
||
| 13 | $em = $this->getDoctrine()->getManager(); |
||
| 14 | //$apiKeyHead= $request->headers->get('apikey'); |
||
| 15 | //$accessToken = $request->headers->get('token'); |
||
| 16 | |||
| 17 | /*if ($accessToken){ |
||
| 18 | $UserFacebook = $this->get('service_facebook_sdk')->setValue($accessToken)->getValue(); |
||
| 19 | |||
| 20 | $apiKey=uniqid('token_'); |
||
| 21 | */ |
||
| 22 | $userFind = $em->getRepository('AppBundle:Customer') |
||
| 23 | ->findUserByFacebook('1607601072588116'); |
||
| 24 | |||
| 25 | if($userFind){ |
||
| 26 | $userRefreshApikey = $em->getRepository('AppBundle:Customer') |
||
| 27 | ->find($userFind[0]['id']); |
||
| 28 | $userRefreshApikey->setApiKey($apiKey); |
||
| 29 | $em->persist($userRefreshApikey); |
||
| 30 | $em->flush($userRefreshApikey); |
||
| 31 | |||
| 32 | } |
||
| 33 | else { |
||
| 34 | $userFindApiKey = $em->getRepository('AppBundle:Customer') |
||
| 35 | ->findUsernameByApiKey($apiKeyHead); |
||
| 36 | |||
| 37 | $userRefreshAll= $em->getRepository('AppBundle:Customer') |
||
| 38 | ->find($userFindApiKey[0]['id']); |
||
| 39 | |||
| 40 | dump($userFindApiKey); |
||
| 41 | |||
| 42 | |||
| 43 | |||
| 44 | $userRefreshAll->setEmail($UserFacebook->getEmail()); |
||
| 45 | $userRefreshAll->setFacebookID($UserFacebook->getId()); |
||
| 46 | $Key = rand(100000, 500000); |
||
| 47 | $apiKey = (string)$Key; |
||
| 48 | $ugserRefreshAll->setApiKey($apiKey); |
||
| 49 | $em = $this->getDoctrine()->getManager(); |
||
| 50 | $em->persist($userRefreshAll); |
||
| 51 | $em->flush(); |
||
| 52 | |||
| 53 | } |
||
| 54 | |||
| 55 | //} |
||
| 56 | // else{ |
||
| 57 | //add first, last name or refreshAll |
||
| 58 | |||
| 59 | // } |
||
| 60 | |||
| 61 | |||
| 62 | |||
| 63 | return $this->render(':default:login.html.twig'); |
||
| 64 | } |
||
| 65 | |||
| 67 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.