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