| Conditions | 3 |
| Paths | 3 |
| Total Lines | 65 |
| Code Lines | 36 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
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 | $apiKeyHead= $request->headers->get('apikey'); |
||
| 14 | $accessToken = $request->headers->get('token'); |
||
| 15 | |||
| 16 | if ($accessToken){ |
||
| 17 | |||
| 18 | |||
| 19 | |||
| 20 | $UserFacebook = $this->get('service_facebook_sdk'); |
||
| 21 | $UserFacebook->setValue($accessToken); |
||
| 22 | |||
| 23 | $UserFacebook = $UserFacebook->getValue(); |
||
| 24 | //dump($UserFacebook); |
||
| 25 | echo $UserFacebook->getId(); |
||
| 26 | |||
| 27 | $Key=rand(100000,500000); |
||
| 28 | $apiKey=(string) $Key; |
||
| 29 | |||
| 30 | $em=$this->getDoctrine()->getManager(); |
||
| 31 | $userFind = $em->getRepository('AppBundle:Customer') |
||
| 32 | ->findUserByFacebookId($UserFacebook->getId()); |
||
| 33 | if($userFind){ |
||
| 34 | |||
| 35 | |||
| 36 | $userRefreshApikey = $em->getRepository('AppBundle:Customer') |
||
| 37 | ->find($userFind[0]['id']); |
||
| 38 | $userRefreshApikey->setApiKey($apiKey); |
||
| 39 | $em->persist($userRefreshApikey); |
||
| 40 | $em->flush($userRefreshApikey); |
||
| 41 | |||
| 42 | } |
||
| 43 | else { |
||
| 44 | $em=$this->getDoctrine()->getManager(); |
||
| 45 | $userFindApiKey = $em->getRepository('AppBundle:Customer') |
||
| 46 | ->findUsernameByApiKey($apiKeyHead); |
||
| 47 | |||
| 48 | $userRefreshAll= $em->getRepository('AppBundle:Customer') |
||
| 49 | ->find($userFindApiKey[0]['id']); |
||
| 50 | |||
| 51 | dump($userFindApiKey); |
||
|
|
|||
| 52 | |||
| 53 | |||
| 54 | |||
| 55 | $userRefreshAll->setEmail($UserFacebook->getEmail()); |
||
| 56 | $userRefreshAll->setFacebookID($UserFacebook->getId()); |
||
| 57 | $Key = rand(100000, 500000); |
||
| 58 | $apiKey = (string)$Key; |
||
| 59 | $userRefreshAll->setApiKey($apiKey); |
||
| 60 | $em = $this->getDoctrine()->getManager(); |
||
| 61 | $em->persist($userRefreshAll); |
||
| 62 | $em->flush(); |
||
| 63 | |||
| 64 | } |
||
| 65 | |||
| 66 | } |
||
| 67 | else{ |
||
| 68 | //add first, last name or refreshAll |
||
| 69 | |||
| 70 | } |
||
| 71 | |||
| 72 | |||
| 73 | |||
| 74 | return $this->render(':default:login.html.twig'); |
||
| 75 | } |
||
| 76 | |||
| 78 |
This check looks for function calls that miss required arguments.