Completed
Push — master ( 75db82...680631 )
by Jacob
02:13
created
display.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 
18 18
 function displayPqp($output, $config) {
19 19
 	
20
-$css = file_get_contents(__DIR__ . '/css/pQp.css');
20
+$css = file_get_contents(__DIR__.'/css/pQp.css');
21 21
 		
22 22
 echo <<<JAVASCRIPT
23 23
 <!-- JavaScript -->
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 
162 162
 echo '<div id="pqp-console" class="pqp-box">';
163 163
 
164
-if($logCount ==  0) {
164
+if ($logCount == 0) {
165 165
 	echo '<h3>This panel has no log items.</h3>';
166 166
 }
167 167
 else {
@@ -179,25 +179,25 @@  discard block
 block discarded – undo
179 179
 		<table class="main" cellspacing="0">';
180 180
 		
181 181
 		$class = '';
182
-		foreach($output['logs']['console']['messages'] as $log) {
182
+		foreach ($output['logs']['console']['messages'] as $log) {
183 183
 			echo '<tr class="log-'.$log['type'].'">
184 184
 				<td class="type">'.$log['type'].'</td>
185 185
 				<td class="'.$class.'">';
186
-			if($log['type'] == 'log') {
186
+			if ($log['type'] == 'log') {
187 187
 				echo '<div><pre>'.$log['data'].'</pre></div>';
188 188
 			}
189
-			elseif($log['type'] == 'memory') {
189
+			elseif ($log['type'] == 'memory') {
190 190
 				echo '<div><pre>'.$log['data'].'</pre> <em>'.$log['data_type'].'</em>: '.$log['name'].' </div>';
191 191
 			}
192
-			elseif($log['type'] == 'speed') {
192
+			elseif ($log['type'] == 'speed') {
193 193
 				echo '<div><pre>'.$log['data'].'</pre> <em>'.$log['name'].'</em></div>';
194 194
 			}
195
-			elseif($log['type'] == 'error') {
195
+			elseif ($log['type'] == 'error') {
196 196
 				echo '<div><em>Line '.$log['line'].'</em> : '.$log['data'].' <pre>'.$log['file'].'</pre></div>';
197 197
 			}
198 198
 		
199 199
 			echo '</td></tr>';
200
-			if($class == '') $class = 'alt';
200
+			if ($class == '') $class = 'alt';
201 201
 			else $class = '';
202 202
 		}
203 203
 			
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 
209 209
 echo '<div id="pqp-speed" class="pqp-box">';
210 210
 
211
-if($output['logs']['speedCount'] ==  0) {
211
+if ($output['logs']['speedCount'] == 0) {
212 212
 	echo '<h3>This panel has no log items.</h3>';
213 213
 }
214 214
 else {
@@ -219,13 +219,13 @@  discard block
 block discarded – undo
219 219
 		<table class="main" cellspacing="0">';
220 220
 		
221 221
 		$class = '';
222
-		foreach($output['logs']['console'] as $log) {
223
-			if($log['type'] == 'speed') {
222
+		foreach ($output['logs']['console'] as $log) {
223
+			if ($log['type'] == 'speed') {
224 224
 				echo '<tr class="log-'.$log['type'].'">
225 225
 				<td class="'.$class.'">';
226 226
 				echo '<div><pre>'.$log['data'].'</pre> <em>'.$log['name'].'</em></div>';
227 227
 				echo '</td></tr>';
228
-				if($class == '') $class = 'alt';
228
+				if ($class == '') $class = 'alt';
229 229
 				else $class = '';
230 230
 			}
231 231
 		}
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 
238 238
 echo '<div id="pqp-queries" class="pqp-box">';
239 239
 
240
-if($output['queryTotals']['count'] ==  0) {
240
+if ($output['queryTotals']['count'] == 0) {
241 241
 	echo '<h3>This panel has no log items.</h3>';
242 242
 }
243 243
 else {
@@ -249,10 +249,10 @@  discard block
 block discarded – undo
249 249
 		<table class="main" cellspacing="0">';
250 250
 		
251 251
 		$class = '';
252
-		foreach($output['queries'] as $query) {
252
+		foreach ($output['queries'] as $query) {
253 253
 			echo '<tr>
254 254
 				<td class="'.$class.'">'.$query['sql'];
255
-			if($query['explain']) {
255
+			if ($query['explain']) {
256 256
 					echo '<em>
257 257
 						Possible keys: <b>'.$query['explain']['possible_keys'].'</b> &middot; 
258 258
 						Key Used: <b>'.$query['explain']['key'].'</b> &middot; 
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 					</em>';
263 263
 			}
264 264
 			echo '</td></tr>';
265
-			if($class == '') $class = 'alt';
265
+			if ($class == '') $class = 'alt';
266 266
 			else $class = '';
267 267
 		}
268 268
 			
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 
274 274
 echo '<div id="pqp-memory" class="pqp-box">';
275 275
 
276
-if($output['logs']['memoryCount'] ==  0) {
276
+if ($output['logs']['memoryCount'] == 0) {
277 277
 	echo '<h3>This panel has no log items.</h3>';
278 278
 }
279 279
 else {
@@ -284,12 +284,12 @@  discard block
 block discarded – undo
284 284
 		<table class="main" cellspacing="0">';
285 285
 		
286 286
 		$class = '';
287
-		foreach($output['logs']['console'] as $log) {
288
-			if($log['type'] == 'memory') {
287
+		foreach ($output['logs']['console'] as $log) {
288
+			if ($log['type'] == 'memory') {
289 289
 				echo '<tr class="log-'.$log['type'].'">';
290 290
 				echo '<td class="'.$class.'"><b>'.$log['data'].'</b> <em>'.$log['dataType'].'</em>: '.$log['name'].'</td>';
291 291
 				echo '</tr>';
292
-				if($class == '') $class = 'alt';
292
+				if ($class == '') $class = 'alt';
293 293
 				else $class = '';
294 294
 			}
295 295
 		}
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 
302 302
 echo '<div id="pqp-files" class="pqp-box">';
303 303
 
304
-if($output['fileTotals']['count'] ==  0) {
304
+if ($output['fileTotals']['count'] == 0) {
305 305
 	echo '<h3>This panel has no log items.</h3>';
306 306
 }
307 307
 else {
@@ -312,10 +312,10 @@  discard block
 block discarded – undo
312 312
 		 </table>
313 313
 		<table class="main" cellspacing="0">';
314 314
 		
315
-		$class ='';
316
-		foreach($output['files'] as $file) {
315
+		$class = '';
316
+		foreach ($output['files'] as $file) {
317 317
 			echo '<tr><td class="'.$class.'"><b>'.$file['size'].'</b> '.$file['name'].'</td></tr>';
318
-			if($class == '') $class = 'alt';
318
+			if ($class == '') $class = 'alt';
319 319
 			else $class = '';
320 320
 		}
321 321
 			
Please login to merge, or discard this patch.
src/Console.php 1 patch
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -15,86 +15,86 @@
 block discarded – undo
15 15
 class Console
16 16
 {
17 17
 
18
-    /** @var  array */
19
-    protected $store = array();
18
+	/** @var  array */
19
+	protected $store = array();
20 20
 
21
-    /**
22
-     * Logs data to the console
23
-     * Accepts any data type
24
-     *
25
-     * @param mixed $data
26
-     */
27
-    public function log($data)
28
-    {
29
-        array_push($this->store, array(
30
-          'data' => $data,
31
-          'type' => 'log'
32
-        ));
33
-    }
21
+	/**
22
+	 * Logs data to the console
23
+	 * Accepts any data type
24
+	 *
25
+	 * @param mixed $data
26
+	 */
27
+	public function log($data)
28
+	{
29
+		array_push($this->store, array(
30
+		  'data' => $data,
31
+		  'type' => 'log'
32
+		));
33
+	}
34 34
 
35
-    /**
36
-     * Logs memory usage of a variable
37
-     * If no parameter is passed in, logs current memory usage
38
-     *
39
-     * @param mixed $object
40
-     * @param string $name
41
-     */
42
-    public function logMemory($object = null, $name = '')
43
-    {
44
-        $memory = memory_get_usage();
45
-        if (!is_null($object)) {
46
-            $memory = strlen(serialize($object));
47
-        }
35
+	/**
36
+	 * Logs memory usage of a variable
37
+	 * If no parameter is passed in, logs current memory usage
38
+	 *
39
+	 * @param mixed $object
40
+	 * @param string $name
41
+	 */
42
+	public function logMemory($object = null, $name = '')
43
+	{
44
+		$memory = memory_get_usage();
45
+		if (!is_null($object)) {
46
+			$memory = strlen(serialize($object));
47
+		}
48 48
 
49
-        array_push($this->store, array(
50
-            'name'      => $name,
51
-            'data'      => $memory,
52
-            'data_type' => gettype($object),
53
-            'type'      => 'memory'
54
-        ));
55
-    }
49
+		array_push($this->store, array(
50
+			'name'      => $name,
51
+			'data'      => $memory,
52
+			'data_type' => gettype($object),
53
+			'type'      => 'memory'
54
+		));
55
+	}
56 56
 
57
-    /**
58
-     * Logs exception with optional message override
59
-     *
60
-     * @param Exception $exception
61
-     * @param string    $message
62
-     */
63
-    public function logError(Exception $exception, $message = '')
64
-    {
65
-        if (empty($message)) {
66
-            $message = $exception->getMessage();
67
-        }
57
+	/**
58
+	 * Logs exception with optional message override
59
+	 *
60
+	 * @param Exception $exception
61
+	 * @param string    $message
62
+	 */
63
+	public function logError(Exception $exception, $message = '')
64
+	{
65
+		if (empty($message)) {
66
+			$message = $exception->getMessage();
67
+		}
68 68
 
69
-        array_push($this->store, array(
70
-            'data' => $message,
71
-            'file' => $exception->getFile(),
72
-            'line' => $exception->getLine(),
73
-            'type' => 'error'
74
-        ));
75
-    }
69
+		array_push($this->store, array(
70
+			'data' => $message,
71
+			'file' => $exception->getFile(),
72
+			'line' => $exception->getLine(),
73
+			'type' => 'error'
74
+		));
75
+	}
76 76
 
77
-    /**
78
-     * Logs current time with optional message
79
-     *
80
-     * @param string $name
81
-     */
82
-    public function logSpeed($name = 'Point in Time')
83
-    {
84
-        array_push($this->store, array(
85
-            'data' => microtime(true),
86
-            'name' => $name,
87
-            'type' => 'speed'
88
-        ));
89
-    }
77
+	/**
78
+	 * Logs current time with optional message
79
+	 *
80
+	 * @param string $name
81
+	 */
82
+	public function logSpeed($name = 'Point in Time')
83
+	{
84
+		array_push($this->store, array(
85
+			'data' => microtime(true),
86
+			'name' => $name,
87
+			'type' => 'speed'
88
+		));
89
+	}
90 90
 
91
-    /**
92
-     * Returns the collected logs
93
-     *
94
-     * @returns array
95
-     */
96
-    public function getLogs()
97
-    {
98
-        return $this->store;
99
-    }
91
+	/**
92
+	 * Returns the collected logs
93
+	 *
94
+	 * @returns array
95
+	 */
96
+	public function getLogs()
97
+	{
98
+		return $this->store;
99
+	}
100 100
 }
Please login to merge, or discard this patch.
src/PhpQuickProfiler.php 2 patches
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
   protected $console;
26 26
 	
27 27
 	public function __construct($console, $startTime = null, $config = '/pqp/') {
28
-    $this->console = $console;
28
+	$this->console = $console;
29 29
 		$this->startTime = $startTime;
30 30
 		$this->config = $config;
31 31
 	}
@@ -35,49 +35,49 @@  discard block
 block discarded – undo
35 35
 	-------------------------------------------*/
36 36
 	
37 37
 	public function gatherConsoleData() {
38
-    $console = array(
39
-      'messages' => array(),
40
-      'totals' => array(
41
-        'log' => 0,
42
-        'memory' => 0,
43
-        'error' => 0,
44
-        'speed' => 0
45
-      ));
38
+	$console = array(
39
+	  'messages' => array(),
40
+	  'totals' => array(
41
+		'log' => 0,
42
+		'memory' => 0,
43
+		'error' => 0,
44
+		'speed' => 0
45
+	  ));
46 46
 		$logs = $this->console->getLogs();
47 47
 			foreach($logs as $log) {
48 48
 				if($log['type'] == 'log') {
49 49
 					$message = array(
50
-            'data' => print_r($log['data'], true),
51
-            'type' => 'log'
52
-          );
53
-          $console['totals']['log']++;
50
+			'data' => print_r($log['data'], true),
51
+			'type' => 'log'
52
+		  );
53
+		  $console['totals']['log']++;
54 54
 				}
55 55
 				elseif($log['type'] == 'memory') {
56 56
 					$message = array(
57
-            'name'    => $log['name'],
58
-            'data_type'    => $log['data_type'],
59
-            'data'   => $this->getReadableFileSize($log['data']),
60
-            'type' => 'memory'
61
-          );
62
-          $console['totals']['memory']++;
57
+			'name'    => $log['name'],
58
+			'data_type'    => $log['data_type'],
59
+			'data'   => $this->getReadableFileSize($log['data']),
60
+			'type' => 'memory'
61
+		  );
62
+		  $console['totals']['memory']++;
63 63
 				}
64 64
 				elseif($log['type'] == 'speed') {
65
-          $message = array(
66
-            'name' => $log['name'],
67
-            'data'    => $this->getReadableTime(($log['data'] - $this->startTime) * 1000),
68
-            'type' => 'speed'
69
-          );
70
-          $console['totals']['speed']++;
65
+		  $message = array(
66
+			'name' => $log['name'],
67
+			'data'    => $this->getReadableTime(($log['data'] - $this->startTime) * 1000),
68
+			'type' => 'speed'
69
+		  );
70
+		  $console['totals']['speed']++;
71 71
 				} else {
72
-          $message = array(
73
-            'data' => $log['data'],
74
-            'type' => 'error',
75
-            'file' => $log['file'],
76
-            'line' => $log['line']
77
-          );
78
-          $console['totals']['error']++;
79
-        }
80
-        array_push($console['messages'], $message);
72
+		  $message = array(
73
+			'data' => $log['data'],
74
+			'type' => 'error',
75
+			'file' => $log['file'],
76
+			'line' => $log['line']
77
+		  );
78
+		  $console['totals']['error']++;
79
+		}
80
+		array_push($console['messages'], $message);
81 81
 			}
82 82
 		$this->output['logs'] = array('console' => $console);
83 83
 	}
@@ -186,19 +186,19 @@  discard block
 block discarded – undo
186 186
 	}
187 187
 	
188 188
 	public function getReadableFileSize($size, $retstring = null) {
189
-        	// adapted from code at http://aidanlister.com/repos/v/function.size_readable.php
190
-	       $sizes = array('bytes', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
189
+			// adapted from code at http://aidanlister.com/repos/v/function.size_readable.php
190
+		   $sizes = array('bytes', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
191 191
 
192
-	       if ($retstring === null) { $retstring = '%01.2f %s'; }
192
+		   if ($retstring === null) { $retstring = '%01.2f %s'; }
193 193
 
194 194
 		$lastsizestring = end($sizes);
195 195
 
196 196
 		foreach ($sizes as $sizestring) {
197
-	       	if ($size < 1024) { break; }
198
-	           if ($sizestring != $lastsizestring) { $size /= 1024; }
199
-	       }
200
-	       if ($sizestring == $sizes[0]) { $retstring = '%01d %s'; } // Bytes aren't normally fractional
201
-	       return sprintf($retstring, $size, $sizestring);
197
+		   	if ($size < 1024) { break; }
198
+			   if ($sizestring != $lastsizestring) { $size /= 1024; }
199
+		   }
200
+		   if ($sizestring == $sizes[0]) { $retstring = '%01d %s'; } // Bytes aren't normally fractional
201
+		   return sprintf($retstring, $size, $sizestring);
202 202
 	}
203 203
 	
204 204
 	public function getReadableTime($time) {
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -44,15 +44,15 @@  discard block
 block discarded – undo
44 44
         'speed' => 0
45 45
       ));
46 46
 		$logs = $this->console->getLogs();
47
-			foreach($logs as $log) {
48
-				if($log['type'] == 'log') {
47
+			foreach ($logs as $log) {
48
+				if ($log['type'] == 'log') {
49 49
 					$message = array(
50 50
             'data' => print_r($log['data'], true),
51 51
             'type' => 'log'
52 52
           );
53 53
           $console['totals']['log']++;
54 54
 				}
55
-				elseif($log['type'] == 'memory') {
55
+				elseif ($log['type'] == 'memory') {
56 56
 					$message = array(
57 57
             'name'    => $log['name'],
58 58
             'data_type'    => $log['data_type'],
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
           );
62 62
           $console['totals']['memory']++;
63 63
 				}
64
-				elseif($log['type'] == 'speed') {
64
+				elseif ($log['type'] == 'speed') {
65 65
           $message = array(
66 66
             'name' => $log['name'],
67 67
             'data'    => $this->getReadableTime(($log['data'] - $this->startTime) * 1000),
@@ -95,14 +95,14 @@  discard block
 block discarded – undo
95 95
 			"largest" => 0,
96 96
 		);
97 97
 
98
-		foreach($files as $key => $file) {
98
+		foreach ($files as $key => $file) {
99 99
 			$size = filesize($file);
100 100
 			$fileList[] = array(
101 101
 					'name' => $file,
102 102
 					'size' => $this->getReadableFileSize($size)
103 103
 				);
104 104
 			$fileTotals['size'] += $size;
105
-			if($size > $fileTotals['largest']) $fileTotals['largest'] = $size;
105
+			if ($size > $fileTotals['largest']) $fileTotals['largest'] = $size;
106 106
 		}
107 107
 		
108 108
 		$fileTotals['size'] = $this->getReadableFileSize($fileTotals['size']);
@@ -132,9 +132,9 @@  discard block
 block discarded – undo
132 132
 		$queryTotals['time'] = 0;
133 133
 		$queries = array();
134 134
 		
135
-		if($this->db != '') {
135
+		if ($this->db != '') {
136 136
 			$queryTotals['count'] += $this->db->queryCount;
137
-			foreach($this->db->queries as $key => $query) {
137
+			foreach ($this->db->queries as $key => $query) {
138 138
 				$query = $this->attemptToExplainQuery($query);
139 139
 				$queryTotals['time'] += $query['time'];
140 140
 				$query['time'] = $this->getReadableTime($query['time']);
@@ -156,8 +156,8 @@  discard block
 block discarded – undo
156 156
 			$sql = 'EXPLAIN '.$query['sql'];
157 157
 			$rs = $this->db->query($sql);
158 158
 		}
159
-		catch(Exception $e) {}
160
-		if($rs) {
159
+		catch (Exception $e) {}
160
+		if ($rs) {
161 161
 			$row = mysql_fetch_array($rs, MYSQL_ASSOC);
162 162
 			$query['explain'] = $row;
163 163
 		}
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 	
171 171
 	public function gatherSpeedData() {
172 172
 		$speedTotals = array();
173
-		$speedTotals['total'] = $this->getReadableTime(($this->getMicroTime() - $this->startTime)*1000);
173
+		$speedTotals['total'] = $this->getReadableTime(($this->getMicroTime() - $this->startTime) * 1000);
174 174
 		$speedTotals['allowed'] = ini_get("max_execution_time");
175 175
 		$this->output['speedTotals'] = $speedTotals;
176 176
 	}
@@ -205,15 +205,15 @@  discard block
 block discarded – undo
205 205
 		$ret = $time;
206 206
 		$formatter = 0;
207 207
 		$formats = array('ms', 's', 'm');
208
-		if($time >= 1000 && $time < 60000) {
208
+		if ($time >= 1000 && $time < 60000) {
209 209
 			$formatter = 1;
210 210
 			$ret = ($time / 1000);
211 211
 		}
212
-		if($time >= 60000) {
212
+		if ($time >= 60000) {
213 213
 			$formatter = 2;
214 214
 			$ret = ($time / 1000) / 60;
215 215
 		}
216
-		$ret = number_format($ret,3,'.','') . ' ' . $formats[$formatter];
216
+		$ret = number_format($ret, 3, '.', '').' '.$formats[$formatter];
217 217
 		return $ret;
218 218
 	}
219 219
 	
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 		$this->gatherMemoryData();
230 230
 		$this->gatherQueryData();
231 231
 		$this->gatherSpeedData();
232
-		require_once __DIR__ . '/../display.php';
232
+		require_once __DIR__.'/../display.php';
233 233
 		displayPqp($this->output, $this->config);
234 234
 	}
235 235
 	
Please login to merge, or discard this patch.