Passed
Push — master ( 0ffeed...f2034e )
by Luiz Kim
02:32
created
src/Service/ExtraDataService.php 1 patch
Braces   +27 added lines, -17 removed lines patch added patch discarded remove patch
@@ -34,8 +34,9 @@  discard block
 block discarded – undo
34 34
             'entity_name' => $class->getShortName(),
35 35
             'value' => $code
36 36
         ]);
37
-        if ($extraData)
38
-            return $this->manager->getRepository($class->getName())->find($extraData->getId());
37
+        if ($extraData) {
38
+                    return $this->manager->getRepository($class->getName())->find($extraData->getId());
39
+        }
39 40
 
40 41
         return null;
41 42
     }
@@ -68,8 +69,9 @@  discard block
 block discarded – undo
68 69
             'context' => $context
69 70
         ]);
70 71
 
71
-        if (!$extraFields)
72
-            $extraFields = new ExtraFields();
72
+        if (!$extraFields) {
73
+                    $extraFields = new ExtraFields();
74
+        }
73 75
 
74 76
         $extraFields->setName($fieldName);
75 77
         $extraFields->setContext($context);
@@ -90,12 +92,15 @@  discard block
 block discarded – undo
90 92
 
91 93
     public function discoveryDevice(&$entity)
92 94
     {
93
-        if ($entity instanceof Device || $entity instanceof DeviceConfig || !$this->request->headers)
94
-            return;
95
+        if ($entity instanceof Device || $entity instanceof DeviceConfig || !$this->request->headers) {
96
+                    return;
97
+        }
95 98
 
96 99
         $deviceId = $this->request->headers->get('DEVICE') ?: $this->getUserIp();
97 100
         if (method_exists($entity, 'setDevice')) {
98
-            if ($entity->getDevice()) return;
101
+            if ($entity->getDevice()) {
102
+                return;
103
+            }
99 104
             $device = $this->deviceService->discoveryDevice($deviceId);
100 105
             $entity->setDevice($device);
101 106
         }
@@ -103,14 +108,16 @@  discard block
 block discarded – undo
103 108
 
104 109
     public function discoveryUser(&$entity)
105 110
     {
106
-        if (method_exists($entity, 'setUser') && !$entity->getUser() && $this->security->getToken())
107
-            $entity->setUser($this->security->getToken()->getUser());
111
+        if (method_exists($entity, 'setUser') && !$entity->getUser() && $this->security->getToken()) {
112
+                    $entity->setUser($this->security->getToken()->getUser());
113
+        }
108 114
     }
109 115
 
110 116
     public function persist(&$entity)
111 117
     {
112
-        if (self::$persisted == true)
113
-            return;
118
+        if (self::$persisted == true) {
119
+                    return;
120
+        }
114 121
         self::$persisted = true;
115 122
 
116 123
         //$this->manager->persist($entity);
@@ -134,15 +141,17 @@  discard block
 block discarded – undo
134 141
         } else {
135 142
             $json =       json_decode($this->request->getContent(), true);
136 143
             $extra_data = isset($json['extra-data']) ? $json['extra-data'] : null;
137
-            if (!$extra_data)
138
-                return;
144
+            if (!$extra_data) {
145
+                            return;
146
+            }
139 147
             $entity_id = $extra_data['entity_id'];
140 148
             $entity_name = $extra_data['entity_name'];
141 149
         }
142 150
 
143 151
 
144
-        if (!$entity_id || !$entity_name)
145
-            return;
152
+        if (!$entity_id || !$entity_name) {
153
+                    return;
154
+        }
146 155
 
147 156
         foreach ($extra_data['data'] as $key => $data) {
148 157
             $extra_fields = $this->manager->getRepository(ExtraFields::class)->find($key);
@@ -153,8 +162,9 @@  discard block
 block discarded – undo
153 162
                 'extra_fields' => $extra_fields
154 163
             ]);
155 164
 
156
-            if (!$extraData)
157
-                $extraData = new ExtraData();
165
+            if (!$extraData) {
166
+                            $extraData = new ExtraData();
167
+            }
158 168
 
159 169
             $extraData->setExtraFields($extra_fields);
160 170
             $extraData->setEntityName($entity_name);
Please login to merge, or discard this patch.