Passed
Push — master ( f3c1db...603c4d )
by Luiz Kim
02:35
created
src/Controller/AddDeviceConfigAction.php 3 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -19,36 +19,36 @@
 block discarded – undo
19 19
 
20 20
 class AddDeviceConfigAction
21 21
 {
22
-  public function __construct(
22
+    public function __construct(
23 23
     private Security $security,
24 24
     private EntityManagerInterface $manager,
25 25
     private ConfigService $configService,
26 26
     private HydratorService $hydratorService
27
-  ) {}
27
+    ) {}
28 28
 
29
-  public function __invoke(Request $request): JsonResponse
30
-  {
29
+    public function __invoke(Request $request): JsonResponse
30
+    {
31 31
     try {
32
-      $json = json_decode($request->getContent(), true);
33
-      $people = $this->manager->getRepository(People::class)->find(preg_replace("/[^0-9]/", "", $json['people']));
34
-      $configs = json_decode($json['configs'], true);
35
-      $device = $this->manager->getRepository(Device::class)->findOneBy([
32
+        $json = json_decode($request->getContent(), true);
33
+        $people = $this->manager->getRepository(People::class)->find(preg_replace("/[^0-9]/", "", $json['people']));
34
+        $configs = json_decode($json['configs'], true);
35
+        $device = $this->manager->getRepository(Device::class)->findOneBy([
36 36
         'people' =>  $people,
37 37
         'device' => $json['device']
38
-      ]);
39
-      if (!$device)
38
+        ]);
39
+        if (!$device)
40 40
         $device  = new Device();
41 41
 
42
-      foreach ($configs as $key => $config)
42
+        foreach ($configs as $key => $config)
43 43
         $device->addConfigs($key,  $config);
44 44
 
45
-      $this->manager->persist($device);
46
-      $this->manager->flush();
45
+        $this->manager->persist($device);
46
+        $this->manager->flush();
47 47
 
48 48
 
49
-      return new JsonResponse($this->hydratorService->item(Config::class, $device->getId(), "device:read"), Response::HTTP_OK);
49
+        return new JsonResponse($this->hydratorService->item(Config::class, $device->getId(), "device:read"), Response::HTTP_OK);
50 50
     } catch (Exception $e) {
51
-      return new JsonResponse($this->hydratorService->error($e));
51
+        return new JsonResponse($this->hydratorService->error($e));
52
+    }
52 53
     }
53
-  }
54 54
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,10 +37,10 @@
 block discarded – undo
37 37
         'device' => $json['device']
38 38
       ]);
39 39
       if (!$device)
40
-        $device  = new Device();
40
+        $device = new Device();
41 41
 
42 42
       foreach ($configs as $key => $config)
43
-        $device->addConfigs($key,  $config);
43
+        $device->addConfigs($key, $config);
44 44
 
45 45
       $this->manager->persist($device);
46 46
       $this->manager->flush();
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -36,11 +36,13 @@
 block discarded – undo
36 36
         'people' =>  $people,
37 37
         'device' => $json['device']
38 38
       ]);
39
-      if (!$device)
40
-        $device  = new Device();
39
+      if (!$device) {
40
+              $device  = new Device();
41
+      }
41 42
 
42
-      foreach ($configs as $key => $config)
43
-        $device->addConfigs($key,  $config);
43
+      foreach ($configs as $key => $config) {
44
+              $device->addConfigs($key,  $config);
45
+      }
44 46
 
45 47
       $this->manager->persist($device);
46 48
       $this->manager->flush();
Please login to merge, or discard this patch.