Passed
Push — master ( 6d5b1e...50d8b5 )
by Luiz Kim
03:12 queued 40s
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) return $extraData;
50 50
 
51 51
         $extraData = new ExtraData();
@@ -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([
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 
133 133
             //$this->manager->persist($entity);
134 134
         } else {
135
-            $json =       json_decode($this->request->getContent(), true);
135
+            $json = json_decode($this->request->getContent(), true);
136 136
             $extra_data = isset($json['extra-data']) ? $json['extra-data'] : null;
137 137
             if (!$extra_data)
138 138
                 return;
Please login to merge, or discard this patch.
Braces   +30 added lines, -18 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
     }
@@ -46,7 +47,9 @@  discard block
 block discarded – undo
46 47
         $class = $this->getEntityName($entity);
47 48
 
48 49
         $extraData = $this->getEntityByExtraData($extraFields,  $code,  $entity);
49
-        if ($extraData) return $extraData;
50
+        if ($extraData) {
51
+            return $extraData;
52
+        }
50 53
 
51 54
         $extraData = new ExtraData();
52 55
         $extraData->setEntityId($entityId);
@@ -68,8 +71,9 @@  discard block
 block discarded – undo
68 71
             'context' => $context
69 72
         ]);
70 73
 
71
-        if (!$extraFields)
72
-            $extraFields = new ExtraFields();
74
+        if (!$extraFields) {
75
+                    $extraFields = new ExtraFields();
76
+        }
73 77
 
74 78
         $extraFields->setName($fieldName);
75 79
         $extraFields->setContext($context);
@@ -90,12 +94,15 @@  discard block
 block discarded – undo
90 94
 
91 95
     public function discoveryDevice(&$entity)
92 96
     {
93
-        if ($entity instanceof Device || $entity instanceof DeviceConfig || !$this->request->headers)
94
-            return;
97
+        if ($entity instanceof Device || $entity instanceof DeviceConfig || !$this->request->headers) {
98
+                    return;
99
+        }
95 100
 
96 101
         $deviceId = $this->request->headers->get('DEVICE') ?: $this->getUserIp();
97 102
         if (method_exists($entity, 'setDevice')) {
98
-            if ($entity->getDevice()) return;
103
+            if ($entity->getDevice()) {
104
+                return;
105
+            }
99 106
             $device = $this->deviceService->discoveryDevice($deviceId);
100 107
             $entity->setDevice($device);
101 108
         }
@@ -103,14 +110,16 @@  discard block
 block discarded – undo
103 110
 
104 111
     public function discoveryUser(&$entity)
105 112
     {
106
-        if (method_exists($entity, 'setUser') && !$entity->getUser() && $this->security->getToken())
107
-            $entity->setUser($this->security->getToken()->getUser());
113
+        if (method_exists($entity, 'setUser') && !$entity->getUser() && $this->security->getToken()) {
114
+                    $entity->setUser($this->security->getToken()->getUser());
115
+        }
108 116
     }
109 117
 
110 118
     public function persist(&$entity)
111 119
     {
112
-        if (self::$persisted == true)
113
-            return;
120
+        if (self::$persisted == true) {
121
+                    return;
122
+        }
114 123
         self::$persisted = true;
115 124
 
116 125
         //$this->manager->persist($entity);
@@ -134,15 +143,17 @@  discard block
 block discarded – undo
134 143
         } else {
135 144
             $json =       json_decode($this->request->getContent(), true);
136 145
             $extra_data = isset($json['extra-data']) ? $json['extra-data'] : null;
137
-            if (!$extra_data)
138
-                return;
146
+            if (!$extra_data) {
147
+                            return;
148
+            }
139 149
             $entity_id = $extra_data['entity_id'];
140 150
             $entity_name = $extra_data['entity_name'];
141 151
         }
142 152
 
143 153
 
144
-        if (!$entity_id || !$entity_name)
145
-            return;
154
+        if (!$entity_id || !$entity_name) {
155
+                    return;
156
+        }
146 157
 
147 158
         foreach ($extra_data['data'] as $key => $data) {
148 159
             $extra_fields = $this->manager->getRepository(ExtraFields::class)->find($key);
@@ -153,8 +164,9 @@  discard block
 block discarded – undo
153 164
                 'extra_fields' => $extra_fields
154 165
             ]);
155 166
 
156
-            if (!$extraData)
157
-                $extraData = new ExtraData();
167
+            if (!$extraData) {
168
+                            $extraData = new ExtraData();
169
+            }
158 170
 
159 171
             $extraData->setExtraFields($extra_fields);
160 172
             $extraData->setEntityName($entity_name);
Please login to merge, or discard this patch.