Passed
Push — master ( 3c9e17...78cd2a )
by Luiz Kim
02:20
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/Service/UserService.php 1 patch
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.
src/Controller/SecurityController.php 1 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/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/CreateUserAction.php 1 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/Controller/ChangePasswordAction.php 1 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.