Completed
Pull Request — master (#137)
by
unknown
15:56
created

CustomerController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
dl 0
loc 70
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A customersLoginAction() 0 65 3
1
<?php
2
3
namespace AppBundle\Controller;
4
5
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6
use Symfony\Component\HttpFoundation\Request;
7
8
class CustomerController extends Controller
9
{
10
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);
0 ignored issues
show
Bug introduced by
The call to dump() misses a required argument $valid.

This check looks for function calls that miss required arguments.

Loading history...
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{
0 ignored issues
show
Unused Code introduced by
This else statement is empty and can be removed.

This check looks for the else branches of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These else branches can be removed.

if (rand(1, 6) > 3) {
print "Check failed";
} else {
    //print "Check succeeded";
}

could be turned into

if (rand(1, 6) > 3) {
    print "Check failed";
}

This is much more concise to read.

Loading history...
68
            //add first, last name or refreshAll
69
70
        }
71
72
73
74
        return $this->render(':default:login.html.twig');
75
    }
76
77
    }
78