Passed
Push — master ( 65c462...83eae8 )
by Luiz Kim
02:34
created
src/Service/ExtraDataService.php 1 patch
Braces   +21 added lines, -13 removed lines patch added patch discarded remove patch
@@ -36,12 +36,15 @@  discard block
 block discarded – undo
36 36
 
37 37
     public function discoveryDevice(&$entity)
38 38
     {
39
-        if ($entity instanceof Device || $entity instanceof DeviceConfig || !$this->request->headers)
40
-            return;
39
+        if ($entity instanceof Device || $entity instanceof DeviceConfig || !$this->request->headers) {
40
+                    return;
41
+        }
41 42
 
42 43
         $deviceId = $this->request->headers->get('DEVICE') ?: $this->getUserIp();
43 44
         if (method_exists($entity, 'setDevice')) {
44
-            if ($entity->getDevice()) return;
45
+            if ($entity->getDevice()) {
46
+                return;
47
+            }
45 48
             $device = $this->deviceService->discoveryDevice($deviceId);
46 49
             $entity->setDevice($device);
47 50
         }
@@ -49,14 +52,16 @@  discard block
 block discarded – undo
49 52
 
50 53
     public function discoveryUser(&$entity)
51 54
     {
52
-        if (method_exists($entity, 'setUser') && !$entity->getUser() && $this->security->getToken())
53
-            $entity->setUser($this->security->getToken()->getUser());
55
+        if (method_exists($entity, 'setUser') && !$entity->getUser() && $this->security->getToken()) {
56
+                    $entity->setUser($this->security->getToken()->getUser());
57
+        }
54 58
     }
55 59
 
56 60
     public function persist(&$entity)
57 61
     {
58
-        if (self::$persisted == true)
59
-            return;
62
+        if (self::$persisted == true) {
63
+                    return;
64
+        }
60 65
         self::$persisted = true;
61 66
 
62 67
         //$this->manager->persist($entity);
@@ -74,15 +79,17 @@  discard block
 block discarded – undo
74 79
         } else {
75 80
             $json =       json_decode($this->request->getContent(), true);
76 81
             $extra_data = isset($json['extra-data']) ? $json['extra-data'] : null;
77
-            if (!$extra_data)
78
-                return;
82
+            if (!$extra_data) {
83
+                            return;
84
+            }
79 85
             $entity_id = $extra_data['entity_id'];
80 86
             $entity_name = $extra_data['entity_name'];
81 87
         }
82 88
 
83 89
 
84
-        if (!$entity_id || !$entity_name)
85
-            return;
90
+        if (!$entity_id || !$entity_name) {
91
+                    return;
92
+        }
86 93
 
87 94
         foreach ($extra_data['data'] as $key => $data) {
88 95
             $extra_fields = $this->manager->getRepository(ExtraFields::class)->find($key);
@@ -93,8 +100,9 @@  discard block
 block discarded – undo
93 100
                 'extra_fields' => $extra_fields
94 101
             ]);
95 102
 
96
-            if (!$extraData)
97
-                $extraData = new ExtraData();
103
+            if (!$extraData) {
104
+                            $extraData = new ExtraData();
105
+            }
98 106
 
99 107
             $extraData->setExtraFields($extra_fields);
100 108
             $extraData->setEntityName($entity_name);
Please login to merge, or discard this patch.