Passed
Push — master ( 0699e2...ae5d2f )
by Luiz Kim
02:38
created
src/Service/ExtraDataService.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
     {
46 46
         $class = $this->getEntityName($entity);
47 47
 
48
-        $extraData = $this->getEntityByExtraData($extraFields,  $code,  $entity);
48
+        $extraData = $this->getEntityByExtraData($extraFields, $code, $entity);
49 49
         if (!$extraData) {
50 50
             $extraData = new ExtraData();
51 51
             $extraData->setEntityId($entityId);
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
         return $this->manager->getRepository($class->getName())->find($extraData->getEntityId());
60 60
     }
61 61
 
62
-    public function discoveryExtraFields(string $fieldName, string $context, ?string $configs = '{}',  ?string $fieldType = 'text', ?bool $required = false): ExtraFields
62
+    public function discoveryExtraFields(string $fieldName, string $context, ?string $configs = '{}', ?string $fieldType = 'text', ?bool $required = false): ExtraFields
63 63
     {
64 64
 
65 65
         $extraFields = $this->manager->getRepository(ExtraFields::class)->findOneBy([
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 
135 135
             //$this->manager->persist($entity);
136 136
         } else {
137
-            $json =       json_decode($this->request->getContent(), true);
137
+            $json = json_decode($this->request->getContent(), true);
138 138
             $extra_data = isset($json['extra-data']) ? $json['extra-data'] : null;
139 139
             if (!$extra_data)
140 140
                 return;
Please login to merge, or discard this 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->getEntityId());
37
+        if ($extraData) {
38
+                    return $this->manager->getRepository($class->getName())->find($extraData->getEntityId());
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);
@@ -136,15 +143,17 @@  discard block
 block discarded – undo
136 143
         } else {
137 144
             $json =       json_decode($this->request->getContent(), true);
138 145
             $extra_data = isset($json['extra-data']) ? $json['extra-data'] : null;
139
-            if (!$extra_data)
140
-                return;
146
+            if (!$extra_data) {
147
+                            return;
148
+            }
141 149
             $entity_id = $extra_data['entity_id'];
142 150
             $entity_name = $extra_data['entity_name'];
143 151
         }
144 152
 
145 153
 
146
-        if (!$entity_id || !$entity_name)
147
-            return;
154
+        if (!$entity_id || !$entity_name) {
155
+                    return;
156
+        }
148 157
 
149 158
         foreach ($extra_data['data'] as $key => $data) {
150 159
             $extra_fields = $this->manager->getRepository(ExtraFields::class)->find($key);
@@ -155,8 +164,9 @@  discard block
 block discarded – undo
155 164
                 'extra_fields' => $extra_fields
156 165
             ]);
157 166
 
158
-            if (!$extraData)
159
-                $extraData = new ExtraData();
167
+            if (!$extraData) {
168
+                            $extraData = new ExtraData();
169
+            }
160 170
 
161 171
             $extraData->setExtraFields($extra_fields);
162 172
             $extraData->setEntityName($entity_name);
Please login to merge, or discard this patch.