Passed
Push — master ( db2ea2...f95733 )
by Luiz Kim
02:09
created
src/Service/UserService.php 2 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -10,25 +10,25 @@  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 createUser(People $people, $username, $password)
29
-  {
28
+    public function createUser(People $people, $username, $password)
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 = new User();
34 34
     $user->setPeople($people);
@@ -38,13 +38,13 @@  discard block
 block discarded – undo
38 38
     $this->manager->persist($user);
39 39
     $this->manager->flush();
40 40
     return $user;
41
-  }
41
+    }
42 42
 
43
-  /**
44
-   * @todo arrumar 
45
-   */
46
-  private function getPermission()
47
-  {
43
+    /**
44
+     * @todo arrumar 
45
+     */
46
+    private function getPermission()
47
+    {
48 48
     return true;
49
-  }
49
+    }
50 50
 }
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 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 createUser(People $people, $username, $password)
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 = new User();
34 36
     $user->setPeople($people);
Please login to merge, or discard this patch.
src/Controller/CreateUserAction.php 2 patches
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.
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.