Passed
Push — master ( 34112b...3e0e76 )
by Luiz Kim
02:08
created
src/Repository/UserRepository.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,13 +28,13 @@
 block discarded – undo
28 28
     public function updatePassword(string $email, string $password): ?User
29 29
     {
30 30
         if ($user = $this->findOneByEmail($email)) {
31
-          $user->setPassword($password);
31
+            $user->setPassword($password);
32 32
 
33
-          $this->getEntityManager()->persist($user);
33
+            $this->getEntityManager()->persist($user);
34 34
 
35
-          $this->getEntityManager()->flush();
35
+            $this->getEntityManager()->flush();
36 36
 
37
-          return $user;
37
+            return $user;
38 38
         }
39 39
     }
40 40
 
Please login to merge, or discard this patch.
src/Controller/SecurityController.php 2 patches
Braces   +12 added lines, -10 removed lines patch added patch discarded remove patch
@@ -27,10 +27,11 @@  discard block
 block discarded – undo
27 27
      */
28 28
     $user = $this->getUser();
29 29
 
30
-    if ($user === null)
31
-      return $this->json([
30
+    if ($user === null) {
31
+          return $this->json([
32 32
         'error' => 'User not found'
33 33
       ]);
34
+    }
34 35
 
35 36
     // get contact data from user
36 37
 
@@ -38,8 +39,9 @@  discard block
 block discarded – undo
38 39
     $code   = '';
39 40
     $number = '';
40 41
 
41
-    if ($user->getPeople()->getEmail()->count() > 0)
42
-      $email = $user->getPeople()->getEmail()->first()->getEmail();
42
+    if ($user->getPeople()->getEmail()->count() > 0) {
43
+          $email = $user->getPeople()->getEmail()->first()->getEmail();
44
+    }
43 45
 
44 46
     if ($user->getPeople()->getPhone()->count() > 0) {
45 47
       $phone  = $user->getPeople()->getPhone()->first();
@@ -65,10 +67,9 @@  discard block
 block discarded – undo
65 67
   {
66 68
     $realName = 'John Doe';
67 69
 
68
-    if ($people->getPeopleType() == 'J')
69
-      $realName = $people->getAlias();
70
-
71
-    else {
70
+    if ($people->getPeopleType() == 'J') {
71
+          $realName = $people->getAlias();
72
+    } else {
72 73
       if ($people->getPeopleType() == 'F') {
73 74
         $realName  = $people->getName();
74 75
         $realName .= ' ' . $people->getAlias();
@@ -82,8 +83,9 @@  discard block
 block discarded – undo
82 83
   private function getCompany(User $user): ?People
83 84
   {
84 85
     $peopleLink = $this->manager->getRepository(People::class)->getPeopleLinks($user->getPeople(), 'employee', 1);
85
-    if ($peopleLink !== false && $peopleLink->getCompany() instanceof People)
86
-      return $peopleLink->getCompany();
86
+    if ($peopleLink !== false && $peopleLink->getCompany() instanceof People) {
87
+          return $peopleLink->getCompany();
88
+    }
87 89
   }
88 90
 
89 91
   private function getCompanyId(User $user): ?int
Please login to merge, or discard this patch.
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -13,22 +13,22 @@  discard block
 block discarded – undo
13 13
 {
14 14
 
15 15
 
16
-  public function __construct(
16
+    public function __construct(
17 17
     private PeopleRoleService $roleService,
18 18
     private EntityManagerInterface $manager,
19
-  ) {}
19
+    ) {}
20 20
 
21
-  public function __invoke(Request $request)
22
-  {
21
+    public function __invoke(Request $request)
22
+    {
23 23
     /**
24 24
      * @var \ControleOnline\Entity\User
25 25
      */
26 26
     $user = $this->getUser();
27 27
 
28 28
     if ($user === null)
29
-      return $this->json([
29
+        return $this->json([
30 30
         'error' => 'User not found'
31
-      ]);
31
+        ]);
32 32
 
33 33
     // get contact data from user
34 34
 
@@ -37,57 +37,57 @@  discard block
 block discarded – undo
37 37
     $number = '';
38 38
 
39 39
     if ($user->getPeople()->getEmail()->count() > 0)
40
-      $email = $user->getPeople()->getEmail()->first()->getEmail();
40
+        $email = $user->getPeople()->getEmail()->first()->getEmail();
41 41
 
42 42
     if ($user->getPeople()->getPhone()->count() > 0) {
43
-      $phone  = $user->getPeople()->getPhone()->first();
44
-      $code   = $phone->getDdd();
45
-      $number = $phone->getPhone();
43
+        $phone  = $user->getPeople()->getPhone()->first();
44
+        $code   = $phone->getDdd();
45
+        $number = $phone->getPhone();
46 46
     }
47 47
 
48 48
     return $this->json([
49
-      'id'   => $user->getPeople()->getId(),
50
-      'username' => $user->getUsername(),
51
-      'roles'    => $user->getRoles(),
52
-      'api_key'  => $user->getApiKey(),
53
-      'people'   => $user->getPeople()->getId(),
54
-      'mycompany'  => $this->getCompanyId($user),
55
-      'realname' => $this->getUserRealName($user->getPeople()),
56
-      'avatar'   => $user->getPeople()->getImage() ? '/files/' . $user->getPeople()->getImage()->getId() . '/download' : null,
57
-      'email'    => $email,
58
-      'phone'    => sprintf('%s%s', $code, $number),
59
-      'active'   => (int) $user->getPeople()->getEnabled(),
49
+        'id'   => $user->getPeople()->getId(),
50
+        'username' => $user->getUsername(),
51
+        'roles'    => $user->getRoles(),
52
+        'api_key'  => $user->getApiKey(),
53
+        'people'   => $user->getPeople()->getId(),
54
+        'mycompany'  => $this->getCompanyId($user),
55
+        'realname' => $this->getUserRealName($user->getPeople()),
56
+        'avatar'   => $user->getPeople()->getImage() ? '/files/' . $user->getPeople()->getImage()->getId() . '/download' : null,
57
+        'email'    => $email,
58
+        'phone'    => sprintf('%s%s', $code, $number),
59
+        'active'   => (int) $user->getPeople()->getEnabled(),
60 60
     ]);
61
-  }
61
+    }
62 62
 
63
-  private function getUserRealName(People $people): string
64
-  {
63
+    private function getUserRealName(People $people): string
64
+    {
65 65
     $realName = 'John Doe';
66 66
 
67 67
     if ($people->getPeopleType() == 'J')
68
-      $realName = $people->getAlias();
68
+        $realName = $people->getAlias();
69 69
 
70 70
     else {
71
-      if ($people->getPeopleType() == 'F') {
71
+        if ($people->getPeopleType() == 'F') {
72 72
         $realName  = $people->getName();
73 73
         $realName .= ' ' . $people->getAlias();
74 74
         $realName  = trim($realName);
75
-      }
75
+        }
76 76
     }
77 77
 
78 78
     return $realName;
79
-  }
79
+    }
80 80
 
81
-  private function getCompany(User $user): ?People
82
-  {
81
+    private function getCompany(User $user): ?People
82
+    {
83 83
     $peopleLink = $this->manager->getRepository(People::class)->getPeopleLinks($user->getPeople(), 'employee', 1);
84 84
     if ($peopleLink !== false && $peopleLink->getCompany() instanceof People)
85
-      return $peopleLink->getCompany();
86
-  }
85
+        return $peopleLink->getCompany();
86
+    }
87 87
 
88
-  private function getCompanyId(User $user): ?int
89
-  {
88
+    private function getCompanyId(User $user): ?int
89
+    {
90 90
     $company = $this->getCompany($user);
91 91
     return $company ? $company->getId() : null;
92
-  }
92
+    }
93 93
 }
Please login to merge, or discard this patch.
src/Controller/Oauth/FacebookController.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
         $this->provider = new Facebook([
27 27
             'clientId'     => $this->clientId,
28 28
             'clientSecret' => $this->clientSecret,
29
-            'redirectUri'  => 'https://' . $this->domainService->getMainDomain(). '/oauth/facebook/return',
29
+            'redirectUri'  => 'https://' . $this->domainService->getMainDomain() . '/oauth/facebook/return',
30 30
             //'hostedDomain' => 'example.com', // optional; used to restrict access to users on your G Suite/Facebook Apps for Business accounts
31 31
         ]);
32 32
     }
Please login to merge, or discard this patch.
src/Controller/Oauth/InstagramController.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
         $this->provider = new Instagram([
28 28
             'clientId'     => $this->clientId,
29 29
             'clientSecret' => $this->clientSecret,
30
-            'redirectUri'  => 'https://' .$this->domainService->getMainDomain() . '/oauth/instagram/return',
30
+            'redirectUri'  => 'https://' . $this->domainService->getMainDomain() . '/oauth/instagram/return',
31 31
             //'hostedDomain' => 'example.com', // optional; used to restrict access to users on your G Suite/Instagram Apps for Business accounts
32 32
         ]);
33 33
     }
Please login to merge, or discard this patch.
src/Controller/ChangePasswordAction.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
   {
24 24
 
25 25
     try {
26
-      $payload   = json_decode($request->getContent());
26
+      $payload = json_decode($request->getContent());
27 27
 
28 28
       $user = $this->service->changePassword($data, $payload->password);
29 29
 
Please login to merge, or discard this patch.
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -12,38 +12,38 @@
 block discarded – undo
12 12
 class ChangePasswordAction
13 13
 {
14 14
 
15
-  public function __construct(
15
+    public function __construct(
16 16
     private EntityManagerInterface $manager,
17 17
     private UserService $service,
18 18
     private HydratorService $hydratorService
19 19
 
20
-  ) {}
20
+    ) {}
21 21
 
22
-  public function __invoke(User $data, Request $request)
23
-  {
22
+    public function __invoke(User $data, Request $request)
23
+    {
24 24
 
25 25
     try {
26
-      $payload   = json_decode($request->getContent());
26
+        $payload   = json_decode($request->getContent());
27 27
 
28
-      $user = $this->service->changePassword($data, $payload->password);
28
+        $user = $this->service->changePassword($data, $payload->password);
29 29
 
30
-      return new JsonResponse(
30
+        return new JsonResponse(
31 31
         $this->hydratorService->item(
32
-          User::class,
33
-          $user->getId(),
34
-          "user:read"
32
+            User::class,
33
+            $user->getId(),
34
+            "user:read"
35 35
         )
36
-      );
36
+        );
37 37
     } catch (\Exception $e) {
38 38
 
39
-      return new JsonResponse([
39
+        return new JsonResponse([
40 40
         'response' => [
41
-          'data'    => [],
42
-          'count'   => 0,
43
-          'error'   => $e->getMessage(),
44
-          'success' => false,
41
+            'data'    => [],
42
+            'count'   => 0,
43
+            'error'   => $e->getMessage(),
44
+            'success' => false,
45 45
         ],
46
-      ], 500);
46
+        ], 500);
47
+    }
47 48
     }
48
-  }
49 49
 }
Please login to merge, or discard this patch.
src/Controller/CreateUserAction.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,8 +24,8 @@
 block discarded – undo
24 24
   {
25 25
 
26 26
     try {
27
-      $payload   = json_decode($request->getContent());
28
-      $people =  $this->manager->getRepository(People::class)->find($payload->people);
27
+      $payload = json_decode($request->getContent());
28
+      $people = $this->manager->getRepository(People::class)->find($payload->people);
29 29
 
30 30
       $user = $this->service->createUser(
31 31
         $people,
Please login to merge, or discard this patch.
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -13,43 +13,43 @@
 block discarded – undo
13 13
 class CreateUserAction
14 14
 {
15 15
 
16
-  public function __construct(
16
+    public function __construct(
17 17
     private EntityManagerInterface $manager,
18 18
     private UserService $service,
19 19
     private HydratorService $hydratorService
20 20
 
21
-  ) {}
21
+    ) {}
22 22
 
23
-  public function __invoke(Request $request)
24
-  {
23
+    public function __invoke(Request $request)
24
+    {
25 25
 
26 26
     try {
27
-      $payload   = json_decode($request->getContent());
28
-      $people =  $this->manager->getRepository(People::class)->find($payload->people);
27
+        $payload   = json_decode($request->getContent());
28
+        $people =  $this->manager->getRepository(People::class)->find($payload->people);
29 29
 
30
-      $user = $this->service->createUser(
30
+        $user = $this->service->createUser(
31 31
         $people,
32 32
         $payload->username,
33 33
         $payload->password
34
-      );
34
+        );
35 35
 
36
-      return new JsonResponse(
36
+        return new JsonResponse(
37 37
         $this->hydratorService->item(
38
-          User::class,
39
-          $user->getId(),
40
-          "user:read"
38
+            User::class,
39
+            $user->getId(),
40
+            "user:read"
41 41
         )
42
-      );
42
+        );
43 43
     } catch (\Exception $e) {
44 44
 
45
-      return new JsonResponse([
45
+        return new JsonResponse([
46 46
         'response' => [
47
-          'data'    => [],
48
-          'count'   => 0,
49
-          'error'   => $e->getMessage(),
50
-          'success' => false,
47
+            'data'    => [],
48
+            'count'   => 0,
49
+            'error'   => $e->getMessage(),
50
+            'success' => false,
51 51
         ],
52
-      ], 500);
52
+        ], 500);
53
+    }
53 54
     }
54
-  }
55 55
 }
Please login to merge, or discard this patch.
src/Service/UserService.php 2 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -10,37 +10,37 @@  discard block
 block discarded – undo
10 10
 
11 11
 class UserService
12 12
 {
13
-  public function __construct(private EntityManagerInterface $manager, private  UserPasswordEncoderInterface $encoder) {}
14
-  public function changePassword(User $user, $password)
15
-  {
13
+    public function __construct(private EntityManagerInterface $manager, private  UserPasswordEncoderInterface $encoder) {}
14
+    public function changePassword(User $user, $password)
15
+    {
16 16
     if (!$this->getPermission())
17
-      throw new Exception("You should not pass!!!", 301);
17
+        throw new Exception("You should not pass!!!", 301);
18 18
 
19 19
     $user->setHash(
20
-      $this->encoder->encodePassword($user, $password)
20
+        $this->encoder->encodePassword($user, $password)
21 21
     );
22 22
 
23 23
     $this->manager->persist($user);
24 24
     $this->manager->flush();
25 25
     return $user;
26
-  }
26
+    }
27 27
 
28
-  public function changeApiKey(User $user)
29
-  {
28
+    public function changeApiKey(User $user)
29
+    {
30 30
     if (!$this->getPermission())
31
-      throw new Exception("You should not pass!!!", 301);
31
+        throw new Exception("You should not pass!!!", 301);
32 32
 
33 33
     $user->generateApiKey();
34 34
 
35 35
     $this->manager->persist($user);
36 36
     $this->manager->flush();
37 37
     return $user;
38
-  }
38
+    }
39 39
 
40
-  public function createUser(People $people, $username, $password)
41
-  {
40
+    public function createUser(People $people, $username, $password)
41
+    {
42 42
     if (!$this->getPermission())
43
-      throw new Exception("You should not pass!!!", 301);
43
+        throw new Exception("You should not pass!!!", 301);
44 44
 
45 45
     $user = new User();
46 46
     $user->setPeople($people);
@@ -50,13 +50,13 @@  discard block
 block discarded – undo
50 50
     $this->manager->persist($user);
51 51
     $this->manager->flush();
52 52
     return $user;
53
-  }
53
+    }
54 54
 
55
-  /**
56
-   * @todo arrumar 
57
-   */
58
-  private function getPermission()
59
-  {
55
+    /**
56
+     * @todo arrumar 
57
+     */
58
+    private function getPermission()
59
+    {
60 60
     return true;
61
-  }
61
+    }
62 62
 }
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
   public function __construct(private EntityManagerInterface $manager, private  UserPasswordEncoderInterface $encoder) {}
14 14
   public function changePassword(User $user, $password)
15 15
   {
16
-    if (!$this->getPermission())
17
-      throw new Exception("You should not pass!!!", 301);
16
+    if (!$this->getPermission()) {
17
+          throw new Exception("You should not pass!!!", 301);
18
+    }
18 19
 
19 20
     $user->setHash(
20 21
       $this->encoder->encodePassword($user, $password)
@@ -27,8 +28,9 @@  discard block
 block discarded – undo
27 28
 
28 29
   public function changeApiKey(User $user)
29 30
   {
30
-    if (!$this->getPermission())
31
-      throw new Exception("You should not pass!!!", 301);
31
+    if (!$this->getPermission()) {
32
+          throw new Exception("You should not pass!!!", 301);
33
+    }
32 34
 
33 35
     $user->generateApiKey();
34 36
 
@@ -39,8 +41,9 @@  discard block
 block discarded – undo
39 41
 
40 42
   public function createUser(People $people, $username, $password)
41 43
   {
42
-    if (!$this->getPermission())
43
-      throw new Exception("You should not pass!!!", 301);
44
+    if (!$this->getPermission()) {
45
+          throw new Exception("You should not pass!!!", 301);
46
+    }
44 47
 
45 48
     $user = new User();
46 49
     $user->setPeople($people);
Please login to merge, or discard this patch.
src/Controller/ChangeApiKeyAction.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -11,37 +11,37 @@
 block discarded – undo
11 11
 class ChangeApiKeyAction
12 12
 {
13 13
 
14
-  public function __construct(
14
+    public function __construct(
15 15
     private EntityManagerInterface $manager,
16 16
     private UserService $service,
17 17
     private HydratorService $hydratorService
18 18
 
19
-  ) {}
19
+    ) {}
20 20
 
21
-  public function __invoke(User $data)
22
-  {
21
+    public function __invoke(User $data)
22
+    {
23 23
 
24 24
     try {
25 25
 
26
-      $user = $this->service->changeApiKey($data);
26
+        $user = $this->service->changeApiKey($data);
27 27
 
28
-      return new JsonResponse(
28
+        return new JsonResponse(
29 29
         $this->hydratorService->item(
30
-          User::class,
31
-          $user->getId(),
32
-          "user:read"
30
+            User::class,
31
+            $user->getId(),
32
+            "user:read"
33 33
         )
34
-      );
34
+        );
35 35
     } catch (\Exception $e) {
36 36
 
37
-      return new JsonResponse([
37
+        return new JsonResponse([
38 38
         'response' => [
39
-          'data'    => [],
40
-          'count'   => 0,
41
-          'error'   => $e->getMessage(),
42
-          'success' => false,
39
+            'data'    => [],
40
+            'count'   => 0,
41
+            'error'   => $e->getMessage(),
42
+            'success' => false,
43 43
         ],
44
-      ], 500);
44
+        ], 500);
45
+    }
45 46
     }
46
-  }
47 47
 }
Please login to merge, or discard this patch.
src/Controller/Oauth/DefaultClientController.php 1 patch
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -97,8 +97,9 @@  discard block
 block discarded – undo
97 97
                 'username'       => $ownerDetails->getEmail(),
98 98
             ]);
99 99
 
100
-        if (!$user)
101
-            $user = $this->createUser($ownerDetails);
100
+        if (!$user) {
101
+                    $user = $this->createUser($ownerDetails);
102
+        }
102 103
 
103 104
         $data = [
104 105
             'id'        => $user->getPeople()->getId(),
@@ -121,20 +122,23 @@  discard block
 block discarded – undo
121 122
         try {
122 123
 
123 124
 
124
-            if ($request->get('code'))
125
-                $token = $this->provider->getAccessToken('authorization_code', [
125
+            if ($request->get('code')) {
126
+                            $token = $this->provider->getAccessToken('authorization_code', [
126 127
                     'code' => $request->get('code')
127 128
                 ]);
129
+            }
128 130
 
129
-            if ($request->get('access_token'))
130
-                $token = new AccessToken([
131
+            if ($request->get('access_token')) {
132
+                            $token = new AccessToken([
131 133
                     'access_token' => $request->get('access_token'),
132 134
                 ]);
135
+            }
133 136
 
134
-            if ($request->get('code'))
135
-                $token = $this->provider->getAccessToken('authorization_code', [
137
+            if ($request->get('code')) {
138
+                            $token = $this->provider->getAccessToken('authorization_code', [
136 139
                     'code' => $request->get('code')
137 140
                 ]);
141
+            }
138 142
 
139 143
 
140 144
             $data = $this->discoveryUser($token);
@@ -163,8 +167,9 @@  discard block
 block discarded – undo
163 167
     {
164 168
         $peopleLink = $user->getPeople()->getLink()->first();
165 169
 
166
-        if ($peopleLink !== false && $peopleLink->getCompany() instanceof People)
167
-            return $peopleLink->getCompany();
170
+        if ($peopleLink !== false && $peopleLink->getCompany() instanceof People) {
171
+                    return $peopleLink->getCompany();
172
+        }
168 173
     }
169 174
 
170 175
     private function getCompanyId(User $user)
Please login to merge, or discard this patch.