Completed
Push — master ( 5befb1...f8eb5f )
by Daniel
02:15
created
source/Compare.php 1 patch
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -50,83 +50,83 @@  discard block
 block discarded – undo
50 50
         echo $this->setHeaderHtml();
51 51
         $rqst         = new \Symfony\Component\HttpFoundation\Request;
52 52
         $superGlobals = $rqst->createFromGlobals();
53
-        $this->prepareForOutputForm(['SuperGlobals' => $superGlobals]);
53
+        $this->prepareForOutputForm([ 'SuperGlobals' => $superGlobals ]);
54 54
         if (!is_null($superGlobals->get('Label'))) {
55
-            $this->processInfos(['sGlobals' => $superGlobals]);
56
-            echo $this->setFormCurlInfos(['SuperGlobals' => $superGlobals]);
57
-            echo $this->setFormInfos(['SuperGlobals' => $superGlobals]);
55
+            $this->processInfos([ 'sGlobals' => $superGlobals ]);
56
+            echo $this->setFormCurlInfos([ 'SuperGlobals' => $superGlobals ]);
57
+            echo $this->setFormInfos([ 'SuperGlobals' => $superGlobals ]);
58 58
         }
59 59
         echo $this->setFooterHtml();
60 60
     }
61 61
 
62 62
     private function displayTableFromMultiLevelArray($inArray)
63 63
     {
64
-        if ((!is_array($inArray['source'])) || (!is_array($inArray['destination']))) {
64
+        if ((!is_array($inArray[ 'source' ])) || (!is_array($inArray[ 'destination' ]))) {
65 65
             return '';
66 66
         }
67
-        $firstRow     = $this->mergeArraysIntoFirstSecond($inArray['source'], $inArray['destination'], [
67
+        $firstRow = $this->mergeArraysIntoFirstSecond($inArray[ 'source' ], $inArray[ 'destination' ], [
68 68
             'first',
69 69
             'second',
70 70
         ]);
71
-        $secondRow    = $this->mergeArraysIntoFirstSecond($inArray['destination'], $inArray['source'], [
71
+        $secondRow = $this->mergeArraysIntoFirstSecond($inArray[ 'destination' ], $inArray[ 'source' ], [
72 72
             'second',
73 73
             'first',
74 74
         ]);
75 75
         $row          = array_merge($firstRow, $secondRow);
76 76
         ksort($row);
77
-        $urlArguments = '?Label=' . $inArray['SuperGlobals']->get('Label');
78
-        $sString      = [];
79
-        $sString[]    = '<table style="width:100%">'
77
+        $urlArguments = '?Label=' . $inArray[ 'SuperGlobals' ]->get('Label');
78
+        $sString      = [ ];
79
+        $sString[ ]    = '<table style="width:100%">'
80 80
                 . '<thead><tr>'
81 81
                 . '<th>Identifier</th>'
82
-                . '<th><a href="' . $this->config['Servers'][$inArray['SuperGlobals']->get('localConfig')]['url']
82
+                . '<th><a href="' . $this->config[ 'Servers' ][ $inArray[ 'SuperGlobals' ]->get('localConfig') ][ 'url' ]
83 83
                 . $urlArguments . '" target="_blank">'
84
-                . $this->config['Servers'][$inArray['SuperGlobals']->get('localConfig')]['name'] . '</a></th>'
85
-                . '<th><a href="' . $this->config['Servers'][$inArray['SuperGlobals']->get('serverConfig')]['url']
84
+                . $this->config[ 'Servers' ][ $inArray[ 'SuperGlobals' ]->get('localConfig') ][ 'name' ] . '</a></th>'
85
+                . '<th><a href="' . $this->config[ 'Servers' ][ $inArray[ 'SuperGlobals' ]->get('serverConfig') ][ 'url' ]
86 86
                 . $urlArguments . '" target="_blank">'
87
-                . $this->config['Servers'][$inArray['SuperGlobals']->get('serverConfig')]['name'] . '</a></th>'
87
+                . $this->config[ 'Servers' ][ $inArray[ 'SuperGlobals' ]->get('serverConfig') ][ 'name' ] . '</a></th>'
88 88
                 . '</tr></thead>'
89 89
                 . '<tbody>';
90
-        if ($inArray['SuperGlobals']->get('displayOnlyDifferent') == '1') {
90
+        if ($inArray[ 'SuperGlobals' ]->get('displayOnlyDifferent') == '1') {
91 91
             $displayOnlyDifferent = true;
92 92
         } else {
93 93
             $displayOnlyDifferent = false;
94 94
         }
95 95
         foreach ($row as $key => $value) {
96 96
             $rowString = '<tr><td style="width:20%;">' . $key . '</td><td style="width:40%;">'
97
-                    . str_replace(',', ', ', $value['first']) . '</td><td style="width:40%;">'
98
-                    . str_replace(',', ', ', $value['second']) . '</td></tr>';
97
+                    . str_replace(',', ', ', $value[ 'first' ]) . '</td><td style="width:40%;">'
98
+                    . str_replace(',', ', ', $value[ 'second' ]) . '</td></tr>';
99 99
             if ($displayOnlyDifferent) {
100
-                if ($value['first'] != $value['second']) {
101
-                    $sString[] = $rowString;
100
+                if ($value[ 'first' ] != $value[ 'second' ]) {
101
+                    $sString[ ] = $rowString;
102 102
                 }
103 103
             } else {
104
-                $sString[] = $rowString;
104
+                $sString[ ] = $rowString;
105 105
             }
106 106
         }
107
-        $sString[] = '</tbody></table>';
107
+        $sString[ ] = '</tbody></table>';
108 108
         return implode('', $sString);
109 109
     }
110 110
 
111 111
     private function getConfiguration()
112 112
     {
113 113
         $strdConfig = $this->configuredDeployedInformators();
114
-        foreach ($strdConfig['informators'] as $key => $value) {
115
-            $this->config['Servers'][] = [
114
+        foreach ($strdConfig[ 'informators' ] as $key => $value) {
115
+            $this->config[ 'Servers' ][ ] = [
116 116
                 'name' => $key,
117 117
                 'url'  => $value,
118 118
             ];
119 119
         }
120
-        $haystack                                         = array_keys($strdConfig['informators']);
121
-        $this->config['Defaults']['Label']                = $strdConfig['default']['label'];
122
-        $this->config['Defaults']['localConfig']          = array_search($strdConfig['default']['source'], $haystack);
123
-        $this->config['Defaults']['serverConfig']         = array_search($strdConfig['default']['target'], $haystack);
124
-        $this->config['Defaults']['displayOnlyDifferent'] = $strdConfig['default']['typeOfResults'];
120
+        $haystack                                         = array_keys($strdConfig[ 'informators' ]);
121
+        $this->config[ 'Defaults' ][ 'Label' ]                = $strdConfig[ 'default' ][ 'label' ];
122
+        $this->config[ 'Defaults' ][ 'localConfig' ]          = array_search($strdConfig[ 'default' ][ 'source' ], $haystack);
123
+        $this->config[ 'Defaults' ][ 'serverConfig' ]         = array_search($strdConfig[ 'default' ][ 'target' ], $haystack);
124
+        $this->config[ 'Defaults' ][ 'displayOnlyDifferent' ] = $strdConfig[ 'default' ][ 'typeOfResults' ];
125 125
     }
126 126
 
127
-    private function mergeArraysIntoFirstSecond($firstArray, $secondArray, $pSequence = ['first', 'second'])
127
+    private function mergeArraysIntoFirstSecond($firstArray, $secondArray, $pSequence = [ 'first', 'second' ])
128 128
     {
129
-        $row = [];
129
+        $row = [ ];
130 130
         foreach ($firstArray as $key => $value) {
131 131
             if (is_array($value)) {
132 132
                 foreach ($value as $key2 => $value2) {
@@ -135,39 +135,39 @@  discard block
 block discarded – undo
135 135
                             if (is_array($value3)) {
136 136
                                 foreach ($value3 as $key4 => $value4) {
137 137
                                     $keyCrt                      = $key . '_' . $key2 . '__' . $key3 . '__' . $key4;
138
-                                    $row[$keyCrt][$pSequence[0]] = $value4;
139
-                                    if (isset($secondArray[$key][$key2][$key3][$key4])) {
140
-                                        $row[$keyCrt][$pSequence[1]] = $secondArray[$key][$key2][$key3][$key4];
138
+                                    $row[ $keyCrt ][ $pSequence[ 0 ] ] = $value4;
139
+                                    if (isset($secondArray[ $key ][ $key2 ][ $key3 ][ $key4 ])) {
140
+                                        $row[ $keyCrt ][ $pSequence[ 1 ] ] = $secondArray[ $key ][ $key2 ][ $key3 ][ $key4 ];
141 141
                                     } else {
142
-                                        $row[$keyCrt][$pSequence[1]] = '';
142
+                                        $row[ $keyCrt ][ $pSequence[ 1 ] ] = '';
143 143
                                     }
144 144
                                 }
145 145
                             } else {
146 146
                                 $keyCrt                      = $key . '_' . $key2 . '__' . $key3;
147
-                                $row[$keyCrt][$pSequence[0]] = $value3;
148
-                                if (isset($secondArray[$key][$key2][$key3])) {
149
-                                    $row[$keyCrt][$pSequence[1]] = $secondArray[$key][$key2][$key3];
147
+                                $row[ $keyCrt ][ $pSequence[ 0 ] ] = $value3;
148
+                                if (isset($secondArray[ $key ][ $key2 ][ $key3 ])) {
149
+                                    $row[ $keyCrt ][ $pSequence[ 1 ] ] = $secondArray[ $key ][ $key2 ][ $key3 ];
150 150
                                 } else {
151
-                                    $row[$keyCrt][$pSequence[1]] = '';
151
+                                    $row[ $keyCrt ][ $pSequence[ 1 ] ] = '';
152 152
                                 }
153 153
                             }
154 154
                         }
155 155
                     } else {
156 156
                         $keyCrt                      = $key . '_' . $key2;
157
-                        $row[$keyCrt][$pSequence[0]] = $value2;
158
-                        if (isset($secondArray[$key][$key2])) {
159
-                            $row[$keyCrt][$pSequence[1]] = $secondArray[$key][$key2];
157
+                        $row[ $keyCrt ][ $pSequence[ 0 ] ] = $value2;
158
+                        if (isset($secondArray[ $key ][ $key2 ])) {
159
+                            $row[ $keyCrt ][ $pSequence[ 1 ] ] = $secondArray[ $key ][ $key2 ];
160 160
                         } else {
161
-                            $row[$keyCrt][$pSequence[1]] = '';
161
+                            $row[ $keyCrt ][ $pSequence[ 1 ] ] = '';
162 162
                         }
163 163
                     }
164 164
                 }
165 165
             } else {
166
-                $row[$key][$pSequence[0]] = $value;
167
-                if (isset($secondArray[$key])) {
168
-                    $row[$key][$pSequence[1]] = $secondArray[$key];
166
+                $row[ $key ][ $pSequence[ 0 ] ] = $value;
167
+                if (isset($secondArray[ $key ])) {
168
+                    $row[ $key ][ $pSequence[ 1 ] ] = $secondArray[ $key ];
169 169
                 } else {
170
-                    $row[$key][$pSequence[1]] = '';
170
+                    $row[ $key ][ $pSequence[ 1 ] ] = '';
171 171
                 }
172 172
             }
173 173
         }
@@ -176,40 +176,40 @@  discard block
 block discarded – undo
176 176
 
177 177
     private function prepareForOutputForm($inArray)
178 178
     {
179
-        $urlToGetLbl = $this->config['Servers'][$this->config['Defaults']['localConfig']]['url']
179
+        $urlToGetLbl = $this->config[ 'Servers' ][ $this->config[ 'Defaults' ][ 'localConfig' ] ][ 'url' ]
180 180
                 . '?Label=---' . urlencode(' List of known labels');
181
-        $knownLabels = $this->getContentFromUrlThroughCurlAsArrayIfJson($urlToGetLbl)['response'];
181
+        $knownLabels = $this->getContentFromUrlThroughCurlAsArrayIfJson($urlToGetLbl)[ 'response' ];
182 182
         echo $this->setOutputForm([
183
-            'Defaults'     => $this->config['Defaults'],
183
+            'Defaults'     => $this->config[ 'Defaults' ],
184 184
             'KnownLabels'  => $knownLabels,
185
-            'Servers'      => $this->config['Servers'],
186
-            'SuperGlobals' => $inArray['SuperGlobals'],
185
+            'Servers'      => $this->config[ 'Servers' ],
186
+            'SuperGlobals' => $inArray[ 'SuperGlobals' ],
187 187
         ]);
188 188
     }
189 189
 
190 190
     private function processInfos($inArray)
191 191
     {
192
-        if (!is_null($inArray['sGlobals']->get('localConfig')) && !is_null($inArray['sGlobals']->get('serverConfig'))) {
193
-            $urlArguments              = '?Label=' . urlencode($inArray['sGlobals']->get('Label'));
194
-            $source                    = $this->config['Servers'][$inArray['sGlobals']->get('localConfig')]['url']
192
+        if (!is_null($inArray[ 'sGlobals' ]->get('localConfig')) && !is_null($inArray[ 'sGlobals' ]->get('serverConfig'))) {
193
+            $urlArguments              = '?Label=' . urlencode($inArray[ 'sGlobals' ]->get('Label'));
194
+            $source                    = $this->config[ 'Servers' ][ $inArray[ 'sGlobals' ]->get('localConfig') ][ 'url' ]
195 195
                     . $urlArguments;
196 196
             $this->localConfiguration  = $this->getContentFromUrlThroughCurlAsArrayIfJson($source);
197
-            $destination               = $this->config['Servers'][$inArray['sGlobals']->get('serverConfig')]['url']
197
+            $destination               = $this->config[ 'Servers' ][ $inArray[ 'sGlobals' ]->get('serverConfig') ][ 'url' ]
198 198
                     . $urlArguments;
199 199
             $this->serverConfiguration = $this->getContentFromUrlThroughCurlAsArrayIfJson($destination);
200 200
         } else {
201
-            $this->localConfiguration  = ['response' => '', 'info' => ''];
202
-            $this->serverConfiguration = ['response' => '', 'info' => ''];
201
+            $this->localConfiguration  = [ 'response' => '', 'info' => '' ];
202
+            $this->serverConfiguration = [ 'response' => '', 'info' => '' ];
203 203
         }
204 204
     }
205 205
 
206 206
     private function setFooterHtml()
207 207
     {
208
-        $sReturn   = [];
209
-        $sReturn[] = '</div><!-- from main Tabber -->';
210
-        $sReturn[] = '<div class="resetOnly author">&copy; 2015 Daniel Popiniuc</div>';
211
-        $sReturn[] = '<hr/>';
212
-        $sReturn[] = '<div class="disclaimer">'
208
+        $sReturn   = [ ];
209
+        $sReturn[ ] = '</div><!-- from main Tabber -->';
210
+        $sReturn[ ] = '<div class="resetOnly author">&copy; 2015 Daniel Popiniuc</div>';
211
+        $sReturn[ ] = '<hr/>';
212
+        $sReturn[ ] = '<div class="disclaimer">'
213 213
                 . 'The developer cannot be liable of any data input or results, '
214 214
                 . 'included but not limited to any implication of these '
215 215
                 . '(anywhere and whomever there might be these)!'
@@ -221,9 +221,9 @@  discard block
 block discarded – undo
221 221
     {
222 222
         return '<div class="tabbertab" id="tabCurl" title="CURL infos">'
223 223
                 . $this->displayTableFromMultiLevelArray([
224
-                    'source'       => $this->localConfiguration['info'],
225
-                    'destination'  => $this->serverConfiguration['info'],
226
-                    'SuperGlobals' => $inArray['SuperGlobals'],
224
+                    'source'       => $this->localConfiguration[ 'info' ],
225
+                    'destination'  => $this->serverConfiguration[ 'info' ],
226
+                    'SuperGlobals' => $inArray[ 'SuperGlobals' ],
227 227
                 ])
228 228
                 . '</div><!--from tabCurl-->';
229 229
     }
@@ -231,12 +231,12 @@  discard block
 block discarded – undo
231 231
     private function setFormInfos($inArray)
232 232
     {
233 233
         return '<div class="tabbertab'
234
-                . (is_null($inArray['SuperGlobals']->get('Label')) ? '' : ' tabbertabdefault')
234
+                . (is_null($inArray[ 'SuperGlobals' ]->get('Label')) ? '' : ' tabbertabdefault')
235 235
                 . '" id="tabConfigs" title="Informations">'
236 236
                 . $this->displayTableFromMultiLevelArray([
237
-                    'source'       => $this->localConfiguration['response'],
238
-                    'destination'  => $this->serverConfiguration['response'],
239
-                    'SuperGlobals' => $inArray['SuperGlobals'],
237
+                    'source'       => $this->localConfiguration[ 'response' ],
238
+                    'destination'  => $this->serverConfiguration[ 'response' ],
239
+                    'SuperGlobals' => $inArray[ 'SuperGlobals' ],
240 240
                 ])
241 241
                 . '</div><!--from tabConfigs-->';
242 242
     }
Please login to merge, or discard this patch.