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