Completed
Push — master ( 7a31d9...5befb1 )
by Daniel
02:21
created
source/OutputFormBuilder.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -34,10 +34,10 @@  discard block
 block discarded – undo
34 34
 
35 35
     private function listOfKnownLabels($inArray)
36 36
     {
37
-        $informatorLabels = array_diff($inArray['KnownLabels'], ['--- List of known labels']);
38
-        $tmpOptions            = [];
37
+        $informatorLabels = array_diff($inArray[ 'KnownLabels' ], [ '--- List of known labels' ]);
38
+        $tmpOptions = [ ];
39 39
         foreach ($informatorLabels as $value) {
40
-            $tmpOptions[] = '<input type="radio" name="Label" id="Label_' . $value . '" value="' . $value . '" '
40
+            $tmpOptions[ ] = '<input type="radio" name="Label" id="Label_' . $value . '" value="' . $value . '" '
41 41
                     . $this->turnRequestedValueIntoCheckboxStatus([
42 42
                         'CheckedValue'  => $value,
43 43
                         'RequestedName' => 'Label',
@@ -52,20 +52,20 @@  discard block
 block discarded – undo
52 52
 
53 53
     private function providers($inArray)
54 54
     {
55
-        $tmpOptions = [];
56
-        foreach ($inArray['Servers'] as $key => $value) {
57
-            $tmpOptions[] = '<a href="' . $value['url'] . '" target="_blank">run-me</a>&nbsp;'
58
-                    . '<input type="radio" name="' . $inArray['ConfigName'] . '" id="'
59
-                    . $inArray['ConfigName'] . '_' . $key . '" value="' . $key . '" '
55
+        $tmpOptions = [ ];
56
+        foreach ($inArray[ 'Servers' ] as $key => $value) {
57
+            $tmpOptions[ ] = '<a href="' . $value[ 'url' ] . '" target="_blank">run-me</a>&nbsp;'
58
+                    . '<input type="radio" name="' . $inArray[ 'ConfigName' ] . '" id="'
59
+                    . $inArray[ 'ConfigName' ] . '_' . $key . '" value="' . $key . '" '
60 60
                     . $this->turnRequestedValueIntoCheckboxStatus([
61 61
                         'CheckedValue'  => (string) $key,
62
-                        'RequestedName' => $inArray['ConfigName'],
62
+                        'RequestedName' => $inArray[ 'ConfigName' ],
63 63
                     ])
64 64
                     . '/>'
65
-                    . '<label for="' . $inArray['ConfigName'] . '_' . $key . '">' . $value['name'] . '</label>';
65
+                    . '<label for="' . $inArray[ 'ConfigName' ] . '_' . $key . '">' . $value[ 'name' ] . '</label>';
66 66
         }
67 67
         return '<fieldset style="float:left;">'
68
-                . '<legend>' . $inArray['TitleStart'] . ' config providers</legend>'
68
+                . '<legend>' . $inArray[ 'TitleStart' ] . ' config providers</legend>'
69 69
                 . implode('<br/>', $tmpOptions)
70 70
                 . '</fieldset>';
71 71
     }
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
         return '<div class="tabbertab" id="tabOptions" title="Options">'
77 77
                 . '<style type="text/css" media="all" scoped>label { width: auto; }</style>'
78 78
                 . '<form method="get" action="'
79
-                . $inArray['SuperGlobals']->server->get('PHP_SELF')
79
+                . $inArray[ 'SuperGlobals' ]->server->get('PHP_SELF')
80 80
                 . '">'
81 81
                 . '<input type="submit" value="Apply" />'
82 82
                 . '<br/>' . implode('', $sReturn)
@@ -87,32 +87,32 @@  discard block
 block discarded – undo
87 87
 
88 88
     private function setFormOptions($inArray)
89 89
     {
90
-        $this->defaults     = $inArray['Defaults'];
91
-        $this->superGlobals = $inArray['SuperGlobals'];
92
-        $sReturn            = [];
93
-        $sReturn[]          = $this->typeOfResults();
94
-        $sReturn[]          = $this->providers([
90
+        $this->defaults     = $inArray[ 'Defaults' ];
91
+        $this->superGlobals = $inArray[ 'SuperGlobals' ];
92
+        $sReturn            = [ ];
93
+        $sReturn[ ]          = $this->typeOfResults();
94
+        $sReturn[ ]          = $this->providers([
95 95
             'ConfigName' => 'localConfig',
96
-            'Servers'    => $inArray['Servers'],
96
+            'Servers'    => $inArray[ 'Servers' ],
97 97
             'TitleStart' => 'Source',
98 98
         ]);
99
-        $sReturn[]          = $this->providers([
99
+        $sReturn[ ] = $this->providers([
100 100
             'ConfigName' => 'serverConfig',
101
-            'Servers'    => $inArray['Servers'],
101
+            'Servers'    => $inArray[ 'Servers' ],
102 102
             'TitleStart' => 'Target',
103 103
         ]);
104
-        $sReturn[]          = $this->listOfKnownLabels(['KnownLabels' => $inArray['KnownLabels']]);
104
+        $sReturn[ ] = $this->listOfKnownLabels([ 'KnownLabels' => $inArray[ 'KnownLabels' ] ]);
105 105
         return $sReturn;
106 106
     }
107 107
 
108 108
     private function turnRequestedValueIntoCheckboxStatus($inArray)
109 109
     {
110
-        if (is_null($this->superGlobals->get($inArray['RequestedName']))) {
111
-            $valToSet = (string) $this->defaults[$inArray['RequestedName']];
112
-            $this->superGlobals->request->set($inArray['RequestedName'], $valToSet);
110
+        if (is_null($this->superGlobals->get($inArray[ 'RequestedName' ]))) {
111
+            $valToSet = (string) $this->defaults[ $inArray[ 'RequestedName' ] ];
112
+            $this->superGlobals->request->set($inArray[ 'RequestedName' ], $valToSet);
113 113
         }
114 114
         $checkboxStatus = '';
115
-        if ($this->superGlobals->get($inArray['RequestedName']) === $inArray['CheckedValue']) {
115
+        if ($this->superGlobals->get($inArray[ 'RequestedName' ]) === $inArray[ 'CheckedValue' ]) {
116 116
             $checkboxStatus = 'checked ';
117 117
         }
118 118
         return $checkboxStatus;
Please login to merge, or discard this patch.
source/Compare.php 1 patch
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -48,89 +48,89 @@  discard block
 block discarded – undo
48 48
     {
49 49
         $this->getConfiguration();
50 50
         $this->applicationFlags = [
51
-            'available_languages' => ['en_US' => 'EN', 'ro_RO' => 'RO'],
51
+            'available_languages' => [ 'en_US' => 'EN', 'ro_RO' => 'RO' ],
52 52
             'default_language'    => 'ro_RO',
53 53
             'name'                => 'Info-Compare'
54 54
         ];
55 55
         echo $this->setHeaderHtml();
56 56
         $rqst                   = new \Symfony\Component\HttpFoundation\Request;
57 57
         $superGlobals           = $rqst->createFromGlobals();
58
-        $this->prepareForOutputForm(['SuperGlobals' => $superGlobals]);
58
+        $this->prepareForOutputForm([ 'SuperGlobals' => $superGlobals ]);
59 59
         if (!is_null($superGlobals->get('Label'))) {
60
-            $this->processInfos(['sGlobals' => $superGlobals]);
61
-            echo $this->setFormCurlInfos(['SuperGlobals' => $superGlobals]);
62
-            echo $this->setFormInfos(['SuperGlobals' => $superGlobals]);
60
+            $this->processInfos([ 'sGlobals' => $superGlobals ]);
61
+            echo $this->setFormCurlInfos([ 'SuperGlobals' => $superGlobals ]);
62
+            echo $this->setFormInfos([ 'SuperGlobals' => $superGlobals ]);
63 63
         }
64 64
         echo $this->setFooterHtml();
65 65
     }
66 66
 
67 67
     private function displayTableFromMultiLevelArray($inArray)
68 68
     {
69
-        if ((!is_array($inArray['source'])) || (!is_array($inArray['destination']))) {
69
+        if ((!is_array($inArray[ 'source' ])) || (!is_array($inArray[ 'destination' ]))) {
70 70
             return '';
71 71
         }
72
-        $firstRow     = $this->mergeArraysIntoFirstSecond($inArray['source'], $inArray['destination'], [
72
+        $firstRow = $this->mergeArraysIntoFirstSecond($inArray[ 'source' ], $inArray[ 'destination' ], [
73 73
             'first',
74 74
             'second',
75 75
         ]);
76
-        $secondRow    = $this->mergeArraysIntoFirstSecond($inArray['destination'], $inArray['source'], [
76
+        $secondRow = $this->mergeArraysIntoFirstSecond($inArray[ 'destination' ], $inArray[ 'source' ], [
77 77
             'second',
78 78
             'first',
79 79
         ]);
80 80
         $row          = array_merge($firstRow, $secondRow);
81 81
         ksort($row);
82
-        $urlArguments = '?Label=' . $inArray['SuperGlobals']->get('Label');
83
-        $sString[]    = '<table style="width:100%">'
82
+        $urlArguments = '?Label=' . $inArray[ 'SuperGlobals' ]->get('Label');
83
+        $sString[ ]    = '<table style="width:100%">'
84 84
                 . '<thead><tr>'
85 85
                 . '<th>Identifier</th>'
86
-                . '<th><a href="' . $this->config['Servers'][$inArray['SuperGlobals']->get('localConfig')]['url']
86
+                . '<th><a href="' . $this->config[ 'Servers' ][ $inArray[ 'SuperGlobals' ]->get('localConfig') ][ 'url' ]
87 87
                 . $urlArguments . '" target="_blank">'
88
-                . $this->config['Servers'][$inArray['SuperGlobals']->get('localConfig')]['name'] . '</a></th>'
89
-                . '<th><a href="' . $this->config['Servers'][$inArray['SuperGlobals']->get('serverConfig')]['url']
88
+                . $this->config[ 'Servers' ][ $inArray[ 'SuperGlobals' ]->get('localConfig') ][ 'name' ] . '</a></th>'
89
+                . '<th><a href="' . $this->config[ 'Servers' ][ $inArray[ 'SuperGlobals' ]->get('serverConfig') ][ 'url' ]
90 90
                 . $urlArguments . '" target="_blank">'
91
-                . $this->config['Servers'][$inArray['SuperGlobals']->get('serverConfig')]['name'] . '</a></th>'
91
+                . $this->config[ 'Servers' ][ $inArray[ 'SuperGlobals' ]->get('serverConfig') ][ 'name' ] . '</a></th>'
92 92
                 . '</tr></thead>'
93 93
                 . '<tbody>';
94
-        if ($inArray['SuperGlobals']->get('displayOnlyDifferent') == '1') {
94
+        if ($inArray[ 'SuperGlobals' ]->get('displayOnlyDifferent') == '1') {
95 95
             $displayOnlyDifferent = true;
96 96
         } else {
97 97
             $displayOnlyDifferent = false;
98 98
         }
99 99
         foreach ($row as $key => $value) {
100 100
             $rowString = '<tr><td style="width:20%;">' . $key . '</td><td style="width:40%;">'
101
-                    . str_replace(',', ', ', $value['first']) . '</td><td style="width:40%;">'
102
-                    . str_replace(',', ', ', $value['second']) . '</td></tr>';
101
+                    . str_replace(',', ', ', $value[ 'first' ]) . '</td><td style="width:40%;">'
102
+                    . str_replace(',', ', ', $value[ 'second' ]) . '</td></tr>';
103 103
             if ($displayOnlyDifferent) {
104
-                if ($value['first'] != $value['second']) {
105
-                    $sString[] = $rowString;
104
+                if ($value[ 'first' ] != $value[ 'second' ]) {
105
+                    $sString[ ] = $rowString;
106 106
                 }
107 107
             } else {
108
-                $sString[] = $rowString;
108
+                $sString[ ] = $rowString;
109 109
             }
110 110
         }
111
-        $sString[] = '</tbody></table>';
111
+        $sString[ ] = '</tbody></table>';
112 112
         return implode('', $sString);
113 113
     }
114 114
 
115 115
     private function getConfiguration()
116 116
     {
117 117
         $strdConfig = $this->configuredDeployedInformators();
118
-        foreach ($strdConfig['informators'] as $key => $value) {
119
-            $this->config['Servers'][] = [
118
+        foreach ($strdConfig[ 'informators' ] as $key => $value) {
119
+            $this->config[ 'Servers' ][ ] = [
120 120
                 'name' => $key,
121 121
                 'url'  => $value,
122 122
             ];
123 123
         }
124
-        $haystack                                         = array_keys($strdConfig['informators']);
125
-        $this->config['Defaults']['Label']                = $strdConfig['default']['label'];
126
-        $this->config['Defaults']['localConfig']          = array_search($strdConfig['default']['source'], $haystack);
127
-        $this->config['Defaults']['serverConfig']         = array_search($strdConfig['default']['target'], $haystack);
128
-        $this->config['Defaults']['displayOnlyDifferent'] = $strdConfig['default']['typeOfResults'];
124
+        $haystack                                         = array_keys($strdConfig[ 'informators' ]);
125
+        $this->config[ 'Defaults' ][ 'Label' ]                = $strdConfig[ 'default' ][ 'label' ];
126
+        $this->config[ 'Defaults' ][ 'localConfig' ]          = array_search($strdConfig[ 'default' ][ 'source' ], $haystack);
127
+        $this->config[ 'Defaults' ][ 'serverConfig' ]         = array_search($strdConfig[ 'default' ][ 'target' ], $haystack);
128
+        $this->config[ 'Defaults' ][ 'displayOnlyDifferent' ] = $strdConfig[ 'default' ][ 'typeOfResults' ];
129 129
     }
130 130
 
131
-    private function mergeArraysIntoFirstSecond($firstArray, $secondArray, $pSequence = ['first', 'second'])
131
+    private function mergeArraysIntoFirstSecond($firstArray, $secondArray, $pSequence = [ 'first', 'second' ])
132 132
     {
133
-        $row = [];
133
+        $row = [ ];
134 134
         foreach ($firstArray as $key => $value) {
135 135
             if (is_array($value)) {
136 136
                 foreach ($value as $key2 => $value2) {
@@ -139,39 +139,39 @@  discard block
 block discarded – undo
139 139
                             if (is_array($value3)) {
140 140
                                 foreach ($value3 as $key4 => $value4) {
141 141
                                     $keyCrt                      = $key . '_' . $key2 . '__' . $key3 . '__' . $key4;
142
-                                    $row[$keyCrt][$pSequence[0]] = $value4;
143
-                                    if (isset($secondArray[$key][$key2][$key3][$key4])) {
144
-                                        $row[$keyCrt][$pSequence[1]] = $secondArray[$key][$key2][$key3][$key4];
142
+                                    $row[ $keyCrt ][ $pSequence[ 0 ] ] = $value4;
143
+                                    if (isset($secondArray[ $key ][ $key2 ][ $key3 ][ $key4 ])) {
144
+                                        $row[ $keyCrt ][ $pSequence[ 1 ] ] = $secondArray[ $key ][ $key2 ][ $key3 ][ $key4 ];
145 145
                                     } else {
146
-                                        $row[$keyCrt][$pSequence[1]] = '';
146
+                                        $row[ $keyCrt ][ $pSequence[ 1 ] ] = '';
147 147
                                     }
148 148
                                 }
149 149
                             } else {
150 150
                                 $keyCrt                      = $key . '_' . $key2 . '__' . $key3;
151
-                                $row[$keyCrt][$pSequence[0]] = $value3;
152
-                                if (isset($secondArray[$key][$key2][$key3])) {
153
-                                    $row[$keyCrt][$pSequence[1]] = $secondArray[$key][$key2][$key3];
151
+                                $row[ $keyCrt ][ $pSequence[ 0 ] ] = $value3;
152
+                                if (isset($secondArray[ $key ][ $key2 ][ $key3 ])) {
153
+                                    $row[ $keyCrt ][ $pSequence[ 1 ] ] = $secondArray[ $key ][ $key2 ][ $key3 ];
154 154
                                 } else {
155
-                                    $row[$keyCrt][$pSequence[1]] = '';
155
+                                    $row[ $keyCrt ][ $pSequence[ 1 ] ] = '';
156 156
                                 }
157 157
                             }
158 158
                         }
159 159
                     } else {
160 160
                         $keyCrt                      = $key . '_' . $key2;
161
-                        $row[$keyCrt][$pSequence[0]] = $value2;
162
-                        if (isset($secondArray[$key][$key2])) {
163
-                            $row[$keyCrt][$pSequence[1]] = $secondArray[$key][$key2];
161
+                        $row[ $keyCrt ][ $pSequence[ 0 ] ] = $value2;
162
+                        if (isset($secondArray[ $key ][ $key2 ])) {
163
+                            $row[ $keyCrt ][ $pSequence[ 1 ] ] = $secondArray[ $key ][ $key2 ];
164 164
                         } else {
165
-                            $row[$keyCrt][$pSequence[1]] = '';
165
+                            $row[ $keyCrt ][ $pSequence[ 1 ] ] = '';
166 166
                         }
167 167
                     }
168 168
                 }
169 169
             } else {
170
-                $row[$key][$pSequence[0]] = $value;
171
-                if (isset($secondArray[$key])) {
172
-                    $row[$key][$pSequence[1]] = $secondArray[$key];
170
+                $row[ $key ][ $pSequence[ 0 ] ] = $value;
171
+                if (isset($secondArray[ $key ])) {
172
+                    $row[ $key ][ $pSequence[ 1 ] ] = $secondArray[ $key ];
173 173
                 } else {
174
-                    $row[$key][$pSequence[1]] = '';
174
+                    $row[ $key ][ $pSequence[ 1 ] ] = '';
175 175
                 }
176 176
             }
177 177
         }
@@ -180,40 +180,40 @@  discard block
 block discarded – undo
180 180
 
181 181
     private function prepareForOutputForm($inArray)
182 182
     {
183
-        $urlToGetLbl = $this->config['Servers'][$this->config['Defaults']['localConfig']]['url']
183
+        $urlToGetLbl = $this->config[ 'Servers' ][ $this->config[ 'Defaults' ][ 'localConfig' ] ][ 'url' ]
184 184
                 . '?Label=---' . urlencode(' List of known labels');
185
-        $knownLabels = $this->getContentFromUrlThroughCurlAsArrayIfJson($urlToGetLbl)['response'];
185
+        $knownLabels = $this->getContentFromUrlThroughCurlAsArrayIfJson($urlToGetLbl)[ 'response' ];
186 186
         echo $this->setOutputForm([
187
-            'Defaults'     => $this->config['Defaults'],
187
+            'Defaults'     => $this->config[ 'Defaults' ],
188 188
             'KnownLabels'  => $knownLabels,
189
-            'Servers'      => $this->config['Servers'],
190
-            'SuperGlobals' => $inArray['SuperGlobals'],
189
+            'Servers'      => $this->config[ 'Servers' ],
190
+            'SuperGlobals' => $inArray[ 'SuperGlobals' ],
191 191
         ]);
192 192
     }
193 193
 
194 194
     private function processInfos($inArray)
195 195
     {
196
-        if (!is_null($inArray['sGlobals']->get('localConfig')) && !is_null($inArray['sGlobals']->get('serverConfig'))) {
197
-            $urlArguments              = '?Label=' . urlencode($inArray['sGlobals']->get('Label'));
198
-            $source                    = $this->config['Servers'][$inArray['sGlobals']->get('localConfig')]['url']
196
+        if (!is_null($inArray[ 'sGlobals' ]->get('localConfig')) && !is_null($inArray[ 'sGlobals' ]->get('serverConfig'))) {
197
+            $urlArguments              = '?Label=' . urlencode($inArray[ 'sGlobals' ]->get('Label'));
198
+            $source                    = $this->config[ 'Servers' ][ $inArray[ 'sGlobals' ]->get('localConfig') ][ 'url' ]
199 199
                     . $urlArguments;
200 200
             $this->localConfiguration  = $this->getContentFromUrlThroughCurlAsArrayIfJson($source);
201
-            $destination               = $this->config['Servers'][$inArray['sGlobals']->get('serverConfig')]['url']
201
+            $destination               = $this->config[ 'Servers' ][ $inArray[ 'sGlobals' ]->get('serverConfig') ][ 'url' ]
202 202
                     . $urlArguments;
203 203
             $this->serverConfiguration = $this->getContentFromUrlThroughCurlAsArrayIfJson($destination);
204 204
         } else {
205
-            $this->localConfiguration  = ['response' => '', 'info' => ''];
206
-            $this->serverConfiguration = ['response' => '', 'info' => ''];
205
+            $this->localConfiguration  = [ 'response' => '', 'info' => '' ];
206
+            $this->serverConfiguration = [ 'response' => '', 'info' => '' ];
207 207
         }
208 208
     }
209 209
 
210 210
     private function setFooterHtml()
211 211
     {
212
-        $sReturn   = [];
213
-        $sReturn[] = '</div><!-- from main Tabber -->';
214
-        $sReturn[] = '<div class="resetOnly author">&copy; 2015 Daniel Popiniuc</div>';
215
-        $sReturn[] = '<hr/>';
216
-        $sReturn[] = '<div class="disclaimer">'
212
+        $sReturn   = [ ];
213
+        $sReturn[ ] = '</div><!-- from main Tabber -->';
214
+        $sReturn[ ] = '<div class="resetOnly author">&copy; 2015 Daniel Popiniuc</div>';
215
+        $sReturn[ ] = '<hr/>';
216
+        $sReturn[ ] = '<div class="disclaimer">'
217 217
                 . 'The developer cannot be liable of any data input or results, '
218 218
                 . 'included but not limited to any implication of these '
219 219
                 . '(anywhere and whomever there might be these)!'
@@ -225,9 +225,9 @@  discard block
 block discarded – undo
225 225
     {
226 226
         return '<div class="tabbertab" id="tabCurl" title="CURL infos">'
227 227
                 . $this->displayTableFromMultiLevelArray([
228
-                    'source'       => $this->localConfiguration['info'],
229
-                    'destination'  => $this->serverConfiguration['info'],
230
-                    'SuperGlobals' => $inArray['SuperGlobals'],
228
+                    'source'       => $this->localConfiguration[ 'info' ],
229
+                    'destination'  => $this->serverConfiguration[ 'info' ],
230
+                    'SuperGlobals' => $inArray[ 'SuperGlobals' ],
231 231
                 ])
232 232
                 . '</div><!--from tabCurl-->';
233 233
     }
@@ -235,12 +235,12 @@  discard block
 block discarded – undo
235 235
     private function setFormInfos($inArray)
236 236
     {
237 237
         return '<div class="tabbertab'
238
-                . (is_null($inArray['SuperGlobals']->get('Label')) ? '' : ' tabbertabdefault')
238
+                . (is_null($inArray[ 'SuperGlobals' ]->get('Label')) ? '' : ' tabbertabdefault')
239 239
                 . '" id="tabConfigs" title="Informations">'
240 240
                 . $this->displayTableFromMultiLevelArray([
241
-                    'source'       => $this->localConfiguration['response'],
242
-                    'destination'  => $this->serverConfiguration['response'],
243
-                    'SuperGlobals' => $inArray['SuperGlobals'],
241
+                    'source'       => $this->localConfiguration[ 'response' ],
242
+                    'destination'  => $this->serverConfiguration[ 'response' ],
243
+                    'SuperGlobals' => $inArray[ 'SuperGlobals' ],
244 244
                 ])
245 245
                 . '</div><!--from tabConfigs-->';
246 246
     }
@@ -249,12 +249,12 @@  discard block
 block discarded – undo
249 249
     {
250 250
         return $this->setHeaderCommon([
251 251
                     'lang'       => 'en-US',
252
-                    'title'      => $this->applicationFlags['name'],
252
+                    'title'      => $this->applicationFlags[ 'name' ],
253 253
                     'css'        => 'css/main.css',
254 254
                     'javascript' => 'js/tabber.min.js',
255 255
                 ])
256 256
                 . $this->setJavascriptContent('document.write(\'<style type="text/css">.tabber{display:none;}</style>\');')
257
-                . '<h1>' . $this->applicationFlags['name'] . '</h1>'
257
+                . '<h1>' . $this->applicationFlags[ 'name' ] . '</h1>'
258 258
                 . '<div class="tabber" id="tab">';
259 259
     }
260 260
 }
Please login to merge, or discard this patch.