@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | Console::log('Ending log below with a sample error.'); |
| 50 | 50 | throw new Exception('Unable to write to log!'); |
| 51 | 51 | } |
| 52 | - catch(Exception $e) { |
|
| 52 | + catch (Exception $e) { |
|
| 53 | 53 | Console::logError($e, 'Sample error logging.'); |
| 54 | 54 | } |
| 55 | 55 | } |
@@ -84,8 +84,8 @@ discard block |
||
| 84 | 84 | $ret = ''; |
| 85 | 85 | $longString = 'This is a really long string that when appended with the . symbol |
| 86 | 86 | will cause memory to be duplicated in order to create the new string.'; |
| 87 | - for($i = 0; $i < 10; $i++) { |
|
| 88 | - $ret = $ret . $longString; |
|
| 87 | + for ($i = 0; $i < 10; $i++) { |
|
| 88 | + $ret = $ret.$longString; |
|
| 89 | 89 | Console::logMemory($ret, 'Watch memory leak -- iteration '.$i); |
| 90 | 90 | } |
| 91 | 91 | } |
@@ -48,8 +48,7 @@ |
||
| 48 | 48 | Console::logMemory($this, 'PQP Example Class : Line '.__LINE__); |
| 49 | 49 | Console::log('Ending log below with a sample error.'); |
| 50 | 50 | throw new Exception('Unable to write to log!'); |
| 51 | - } |
|
| 52 | - catch(Exception $e) { |
|
| 51 | + } catch(Exception $e) { |
|
| 53 | 52 | Console::logError($e, 'Sample error logging.'); |
| 54 | 53 | } |
| 55 | 54 | } |
@@ -15,86 +15,86 @@ |
||
| 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 | } |
@@ -5,112 +5,112 @@ |
||
| 5 | 5 | class ConsoleTest extends PHPUnit_Framework_TestCase |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - public function __construct() |
|
| 9 | - { |
|
| 10 | - } |
|
| 11 | - |
|
| 12 | - public function testLog() |
|
| 13 | - { |
|
| 14 | - $data = array( |
|
| 15 | - 'key' => 'value' |
|
| 16 | - ); |
|
| 17 | - |
|
| 18 | - $console = new Console(); |
|
| 19 | - $console->log($data); |
|
| 20 | - $store = $this->getProtectedStore($console); |
|
| 21 | - $log = array_pop($store); |
|
| 22 | - |
|
| 23 | - $this->assertSame($data, $log['data']); |
|
| 24 | - $this->assertEquals('log', $log['type']); |
|
| 25 | - } |
|
| 26 | - |
|
| 27 | - public function testLogMemory() |
|
| 28 | - { |
|
| 29 | - $data = array( |
|
| 30 | - 'key' => 'value' |
|
| 31 | - ); |
|
| 32 | - $memory = strlen(serialize($data)); |
|
| 33 | - $name = 'Test Array'; |
|
| 34 | - |
|
| 35 | - $console = new Console(); |
|
| 36 | - $console->logMemory($data, $name); |
|
| 37 | - $store = $this->getProtectedStore($console); |
|
| 38 | - $log = array_pop($store); |
|
| 39 | - |
|
| 40 | - $this->assertEquals($name, $log['name']); |
|
| 41 | - $this->assertEquals($memory, $log['data']); |
|
| 42 | - $this->assertEquals('array', $log['data_type']); |
|
| 43 | - $this->assertEquals('memory', $log['type']); |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - public function testLogError() |
|
| 47 | - { |
|
| 48 | - $error = new Exception('Test Exception'); |
|
| 49 | - |
|
| 50 | - $console = new Console(); |
|
| 51 | - $console->logError($error); |
|
| 52 | - $store = $this->getProtectedStore($console); |
|
| 53 | - $log = array_pop($store); |
|
| 54 | - |
|
| 55 | - $this->assertEquals($error->getMessage(), $log['data']); |
|
| 56 | - $this->assertEquals($error->getFile(), $log['file']); |
|
| 57 | - $this->assertEquals($error->getLine(), $log['line']); |
|
| 58 | - $this->assertEquals('error', $log['type']); |
|
| 59 | - |
|
| 60 | - $error = new Exception('Test Exception'); |
|
| 61 | - $message = 'override message'; |
|
| 62 | - |
|
| 63 | - $console = new Console(); |
|
| 64 | - $console->logError($error, $message); |
|
| 65 | - $store = $this->getProtectedStore($console); |
|
| 66 | - $log = array_pop($store); |
|
| 67 | - |
|
| 68 | - $this->assertEquals($message, $log['data']); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - public function testLogSpeed() |
|
| 72 | - { |
|
| 73 | - $name = 'Test Speed'; |
|
| 74 | - |
|
| 75 | - $console = new Console(); |
|
| 76 | - $console->logSpeed($name); |
|
| 77 | - $store = $this->getProtectedStore($console); |
|
| 78 | - $log = array_pop($store); |
|
| 79 | - |
|
| 80 | - $this->assertEquals($name, $log['name']); |
|
| 81 | - $this->assertEquals('speed', $log['type']); |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - public function testGetLogs() |
|
| 85 | - { |
|
| 86 | - $store = array( |
|
| 87 | - array( |
|
| 88 | - 'data' => 'a string', |
|
| 89 | - 'type' => 'log' |
|
| 90 | - ), |
|
| 91 | - array( |
|
| 92 | - 'name' => '', |
|
| 93 | - 'data' => 123, |
|
| 94 | - 'data_type' => 'array', |
|
| 95 | - 'type' => 'memory' |
|
| 96 | - ) |
|
| 97 | - ); |
|
| 98 | - |
|
| 99 | - $console = new Console(); |
|
| 100 | - |
|
| 101 | - $reflectedConsole = new ReflectionClass(get_class($console)); |
|
| 102 | - $reflectedProperty = $reflectedConsole->getProperty('store'); |
|
| 103 | - $reflectedProperty->setAccessible(true); |
|
| 104 | - $reflectedProperty->setValue($console, $store); |
|
| 105 | - |
|
| 106 | - $this->assertSame($store, $console->getLogs()); |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - protected function getProtectedStore(Console $console) |
|
| 110 | - { |
|
| 111 | - $reflectedConsole = new ReflectionClass(get_class($console)); |
|
| 112 | - $reflectedProperty = $reflectedConsole->getProperty('store'); |
|
| 113 | - $reflectedProperty->setAccessible(true); |
|
| 114 | - return $reflectedProperty->getValue($console); |
|
| 115 | - } |
|
| 8 | + public function __construct() |
|
| 9 | + { |
|
| 10 | + } |
|
| 11 | + |
|
| 12 | + public function testLog() |
|
| 13 | + { |
|
| 14 | + $data = array( |
|
| 15 | + 'key' => 'value' |
|
| 16 | + ); |
|
| 17 | + |
|
| 18 | + $console = new Console(); |
|
| 19 | + $console->log($data); |
|
| 20 | + $store = $this->getProtectedStore($console); |
|
| 21 | + $log = array_pop($store); |
|
| 22 | + |
|
| 23 | + $this->assertSame($data, $log['data']); |
|
| 24 | + $this->assertEquals('log', $log['type']); |
|
| 25 | + } |
|
| 26 | + |
|
| 27 | + public function testLogMemory() |
|
| 28 | + { |
|
| 29 | + $data = array( |
|
| 30 | + 'key' => 'value' |
|
| 31 | + ); |
|
| 32 | + $memory = strlen(serialize($data)); |
|
| 33 | + $name = 'Test Array'; |
|
| 34 | + |
|
| 35 | + $console = new Console(); |
|
| 36 | + $console->logMemory($data, $name); |
|
| 37 | + $store = $this->getProtectedStore($console); |
|
| 38 | + $log = array_pop($store); |
|
| 39 | + |
|
| 40 | + $this->assertEquals($name, $log['name']); |
|
| 41 | + $this->assertEquals($memory, $log['data']); |
|
| 42 | + $this->assertEquals('array', $log['data_type']); |
|
| 43 | + $this->assertEquals('memory', $log['type']); |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + public function testLogError() |
|
| 47 | + { |
|
| 48 | + $error = new Exception('Test Exception'); |
|
| 49 | + |
|
| 50 | + $console = new Console(); |
|
| 51 | + $console->logError($error); |
|
| 52 | + $store = $this->getProtectedStore($console); |
|
| 53 | + $log = array_pop($store); |
|
| 54 | + |
|
| 55 | + $this->assertEquals($error->getMessage(), $log['data']); |
|
| 56 | + $this->assertEquals($error->getFile(), $log['file']); |
|
| 57 | + $this->assertEquals($error->getLine(), $log['line']); |
|
| 58 | + $this->assertEquals('error', $log['type']); |
|
| 59 | + |
|
| 60 | + $error = new Exception('Test Exception'); |
|
| 61 | + $message = 'override message'; |
|
| 62 | + |
|
| 63 | + $console = new Console(); |
|
| 64 | + $console->logError($error, $message); |
|
| 65 | + $store = $this->getProtectedStore($console); |
|
| 66 | + $log = array_pop($store); |
|
| 67 | + |
|
| 68 | + $this->assertEquals($message, $log['data']); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + public function testLogSpeed() |
|
| 72 | + { |
|
| 73 | + $name = 'Test Speed'; |
|
| 74 | + |
|
| 75 | + $console = new Console(); |
|
| 76 | + $console->logSpeed($name); |
|
| 77 | + $store = $this->getProtectedStore($console); |
|
| 78 | + $log = array_pop($store); |
|
| 79 | + |
|
| 80 | + $this->assertEquals($name, $log['name']); |
|
| 81 | + $this->assertEquals('speed', $log['type']); |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + public function testGetLogs() |
|
| 85 | + { |
|
| 86 | + $store = array( |
|
| 87 | + array( |
|
| 88 | + 'data' => 'a string', |
|
| 89 | + 'type' => 'log' |
|
| 90 | + ), |
|
| 91 | + array( |
|
| 92 | + 'name' => '', |
|
| 93 | + 'data' => 123, |
|
| 94 | + 'data_type' => 'array', |
|
| 95 | + 'type' => 'memory' |
|
| 96 | + ) |
|
| 97 | + ); |
|
| 98 | + |
|
| 99 | + $console = new Console(); |
|
| 100 | + |
|
| 101 | + $reflectedConsole = new ReflectionClass(get_class($console)); |
|
| 102 | + $reflectedProperty = $reflectedConsole->getProperty('store'); |
|
| 103 | + $reflectedProperty->setAccessible(true); |
|
| 104 | + $reflectedProperty->setValue($console, $store); |
|
| 105 | + |
|
| 106 | + $this->assertSame($store, $console->getLogs()); |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + protected function getProtectedStore(Console $console) |
|
| 110 | + { |
|
| 111 | + $reflectedConsole = new ReflectionClass(get_class($console)); |
|
| 112 | + $reflectedProperty = $reflectedConsole->getProperty('store'); |
|
| 113 | + $reflectedProperty->setAccessible(true); |
|
| 114 | + return $reflectedProperty->getValue($console); |
|
| 115 | + } |
|
| 116 | 116 | } |
@@ -54,8 +54,7 @@ discard block |
||
| 54 | 54 | 'type' => 'log' |
| 55 | 55 | ); |
| 56 | 56 | $console['totals']['log']++; |
| 57 | - } |
|
| 58 | - elseif($log['type'] == 'memory') { |
|
| 57 | + } elseif($log['type'] == 'memory') { |
|
| 59 | 58 | $message = array( |
| 60 | 59 | 'name' => $log['name'], |
| 61 | 60 | 'data_type' => $log['data_type'], |
@@ -63,8 +62,7 @@ discard block |
||
| 63 | 62 | 'type' => 'memory' |
| 64 | 63 | ); |
| 65 | 64 | $console['totals']['memory']++; |
| 66 | - } |
|
| 67 | - elseif($log['type'] == 'speed') { |
|
| 65 | + } elseif($log['type'] == 'speed') { |
|
| 68 | 66 | $message = array( |
| 69 | 67 | 'name' => $log['name'], |
| 70 | 68 | 'data' => $this->getReadableTime(($log['data'] - $this->startTime) * 1000), |
@@ -105,7 +103,9 @@ discard block |
||
| 105 | 103 | 'size' => $this->getReadableFileSize($size) |
| 106 | 104 | ); |
| 107 | 105 | $fileTotals['size'] += $size; |
| 108 | - if($size > $fileTotals['largest']) $fileTotals['largest'] = $size; |
|
| 106 | + if($size > $fileTotals['largest']) { |
|
| 107 | + $fileTotals['largest'] = $size; |
|
| 108 | + } |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | $fileTotals['size'] = $this->getReadableFileSize($fileTotals['size']); |
@@ -158,8 +158,7 @@ discard block |
||
| 158 | 158 | try { |
| 159 | 159 | $sql = 'EXPLAIN '.$query['sql']; |
| 160 | 160 | $rs = $this->db->query($sql); |
| 161 | - } |
|
| 162 | - catch(Exception $e) {} |
|
| 161 | + } catch(Exception $e) {} |
|
| 163 | 162 | if($rs) { |
| 164 | 163 | $row = mysql_fetch_array($rs, MYSQL_ASSOC); |
| 165 | 164 | $query['explain'] = $row; |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | protected $startTime; |
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | - * @param Particletree\Pqp\Console $console |
|
| 25 | + * @param Console $console |
|
| 26 | 26 | * @param integer $startTime |
| 27 | 27 | */ |
| 28 | 28 | public function __construct(Console $console, $startTime = null) |
@@ -15,78 +15,78 @@ discard block |
||
| 15 | 15 | class PhpQuickProfiler |
| 16 | 16 | { |
| 17 | 17 | |
| 18 | - /** @var Particletree\Pqp\Console */ |
|
| 19 | - protected $console; |
|
| 18 | + /** @var Particletree\Pqp\Console */ |
|
| 19 | + protected $console; |
|
| 20 | 20 | |
| 21 | - /** @var integer */ |
|
| 22 | - protected $startTime; |
|
| 21 | + /** @var integer */ |
|
| 22 | + protected $startTime; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * @param Particletree\Pqp\Console $console |
|
| 26 | - * @param integer $startTime |
|
| 27 | - */ |
|
| 28 | - public function __construct(Console $console, $startTime = null) |
|
| 29 | - { |
|
| 30 | - $this->console = $console; |
|
| 24 | + /** |
|
| 25 | + * @param Particletree\Pqp\Console $console |
|
| 26 | + * @param integer $startTime |
|
| 27 | + */ |
|
| 28 | + public function __construct(Console $console, $startTime = null) |
|
| 29 | + { |
|
| 30 | + $this->console = $console; |
|
| 31 | 31 | |
| 32 | - if (is_null($startTime)) { |
|
| 33 | - $startTime = microtime(true); |
|
| 34 | - } |
|
| 35 | - $this->startTime = $startTime; |
|
| 36 | - } |
|
| 32 | + if (is_null($startTime)) { |
|
| 33 | + $startTime = microtime(true); |
|
| 34 | + } |
|
| 35 | + $this->startTime = $startTime; |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Formats the logs from the console |
|
| 40 | - * |
|
| 41 | - * @return array |
|
| 42 | - */ |
|
| 43 | - protected function gatherConsoleData() |
|
| 44 | - { |
|
| 45 | - $console = array( |
|
| 46 | - 'messages' => array(), |
|
| 47 | - 'totals' => array( |
|
| 48 | - 'log' => 0, |
|
| 49 | - 'memory' => 0, |
|
| 50 | - 'error' => 0, |
|
| 51 | - 'speed' => 0 |
|
| 52 | - )); |
|
| 53 | - $logs = $this->console->getLogs(); |
|
| 54 | - foreach($logs as $log) { |
|
| 55 | - if($log['type'] == 'log') { |
|
| 56 | - $message = array( |
|
| 57 | - 'data' => print_r($log['data'], true), |
|
| 58 | - 'type' => 'log' |
|
| 59 | - ); |
|
| 60 | - $console['totals']['log']++; |
|
| 61 | - } |
|
| 62 | - elseif($log['type'] == 'memory') { |
|
| 63 | - $message = array( |
|
| 64 | - 'name' => $log['name'], |
|
| 65 | - 'data_type' => $log['data_type'], |
|
| 66 | - 'data' => $this->getReadableFileSize($log['data']), |
|
| 67 | - 'type' => 'memory' |
|
| 68 | - ); |
|
| 69 | - $console['totals']['memory']++; |
|
| 70 | - } |
|
| 71 | - elseif($log['type'] == 'speed') { |
|
| 72 | - $message = array( |
|
| 73 | - 'name' => $log['name'], |
|
| 74 | - 'data' => $this->getReadableTime(($log['data'] - $this->startTime) * 1000), |
|
| 75 | - 'type' => 'speed' |
|
| 76 | - ); |
|
| 77 | - $console['totals']['speed']++; |
|
| 78 | - } else { |
|
| 79 | - $message = array( |
|
| 80 | - 'data' => $log['data'], |
|
| 81 | - 'type' => 'error', |
|
| 82 | - 'file' => $log['file'], |
|
| 83 | - 'line' => $log['line'] |
|
| 84 | - ); |
|
| 85 | - $console['totals']['error']++; |
|
| 86 | - } |
|
| 87 | - array_push($console['messages'], $message); |
|
| 88 | - } |
|
| 89 | - $this->output['logs'] = array('console' => $console); |
|
| 38 | + /** |
|
| 39 | + * Formats the logs from the console |
|
| 40 | + * |
|
| 41 | + * @return array |
|
| 42 | + */ |
|
| 43 | + protected function gatherConsoleData() |
|
| 44 | + { |
|
| 45 | + $console = array( |
|
| 46 | + 'messages' => array(), |
|
| 47 | + 'totals' => array( |
|
| 48 | + 'log' => 0, |
|
| 49 | + 'memory' => 0, |
|
| 50 | + 'error' => 0, |
|
| 51 | + 'speed' => 0 |
|
| 52 | + )); |
|
| 53 | + $logs = $this->console->getLogs(); |
|
| 54 | + foreach($logs as $log) { |
|
| 55 | + if($log['type'] == 'log') { |
|
| 56 | + $message = array( |
|
| 57 | + 'data' => print_r($log['data'], true), |
|
| 58 | + 'type' => 'log' |
|
| 59 | + ); |
|
| 60 | + $console['totals']['log']++; |
|
| 61 | + } |
|
| 62 | + elseif($log['type'] == 'memory') { |
|
| 63 | + $message = array( |
|
| 64 | + 'name' => $log['name'], |
|
| 65 | + 'data_type' => $log['data_type'], |
|
| 66 | + 'data' => $this->getReadableFileSize($log['data']), |
|
| 67 | + 'type' => 'memory' |
|
| 68 | + ); |
|
| 69 | + $console['totals']['memory']++; |
|
| 70 | + } |
|
| 71 | + elseif($log['type'] == 'speed') { |
|
| 72 | + $message = array( |
|
| 73 | + 'name' => $log['name'], |
|
| 74 | + 'data' => $this->getReadableTime(($log['data'] - $this->startTime) * 1000), |
|
| 75 | + 'type' => 'speed' |
|
| 76 | + ); |
|
| 77 | + $console['totals']['speed']++; |
|
| 78 | + } else { |
|
| 79 | + $message = array( |
|
| 80 | + 'data' => $log['data'], |
|
| 81 | + 'type' => 'error', |
|
| 82 | + 'file' => $log['file'], |
|
| 83 | + 'line' => $log['line'] |
|
| 84 | + ); |
|
| 85 | + $console['totals']['error']++; |
|
| 86 | + } |
|
| 87 | + array_push($console['messages'], $message); |
|
| 88 | + } |
|
| 89 | + $this->output['logs'] = array('console' => $console); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /*------------------------------------------- |
@@ -94,28 +94,28 @@ discard block |
||
| 94 | 94 | -------------------------------------------*/ |
| 95 | 95 | |
| 96 | 96 | public function gatherFileData() { |
| 97 | - $files = get_included_files(); |
|
| 98 | - $fileList = array(); |
|
| 99 | - $fileTotals = array( |
|
| 100 | - "count" => count($files), |
|
| 101 | - "size" => 0, |
|
| 102 | - "largest" => 0, |
|
| 103 | - ); |
|
| 97 | + $files = get_included_files(); |
|
| 98 | + $fileList = array(); |
|
| 99 | + $fileTotals = array( |
|
| 100 | + "count" => count($files), |
|
| 101 | + "size" => 0, |
|
| 102 | + "largest" => 0, |
|
| 103 | + ); |
|
| 104 | 104 | |
| 105 | - foreach($files as $file) { |
|
| 106 | - $size = filesize($file); |
|
| 107 | - $fileList[] = array( |
|
| 108 | - 'name' => $file, |
|
| 109 | - 'size' => $this->getReadableFileSize($size) |
|
| 110 | - ); |
|
| 111 | - $fileTotals['size'] += $size; |
|
| 112 | - if($size > $fileTotals['largest']) $fileTotals['largest'] = $size; |
|
| 113 | - } |
|
| 105 | + foreach($files as $file) { |
|
| 106 | + $size = filesize($file); |
|
| 107 | + $fileList[] = array( |
|
| 108 | + 'name' => $file, |
|
| 109 | + 'size' => $this->getReadableFileSize($size) |
|
| 110 | + ); |
|
| 111 | + $fileTotals['size'] += $size; |
|
| 112 | + if($size > $fileTotals['largest']) $fileTotals['largest'] = $size; |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | - $fileTotals['size'] = $this->getReadableFileSize($fileTotals['size']); |
|
| 116 | - $fileTotals['largest'] = $this->getReadableFileSize($fileTotals['largest']); |
|
| 117 | - $this->output['files'] = $fileList; |
|
| 118 | - $this->output['fileTotals'] = $fileTotals; |
|
| 115 | + $fileTotals['size'] = $this->getReadableFileSize($fileTotals['size']); |
|
| 116 | + $fileTotals['largest'] = $this->getReadableFileSize($fileTotals['largest']); |
|
| 117 | + $this->output['files'] = $fileList; |
|
| 118 | + $this->output['fileTotals'] = $fileTotals; |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | /*------------------------------------------- |
@@ -123,10 +123,10 @@ discard block |
||
| 123 | 123 | -------------------------------------------*/ |
| 124 | 124 | |
| 125 | 125 | public function gatherMemoryData() { |
| 126 | - $memoryTotals = array(); |
|
| 127 | - $memoryTotals['used'] = $this->getReadableFileSize(memory_get_peak_usage()); |
|
| 128 | - $memoryTotals['total'] = ini_get("memory_limit"); |
|
| 129 | - $this->output['memoryTotals'] = $memoryTotals; |
|
| 126 | + $memoryTotals = array(); |
|
| 127 | + $memoryTotals['used'] = $this->getReadableFileSize(memory_get_peak_usage()); |
|
| 128 | + $memoryTotals['total'] = ini_get("memory_limit"); |
|
| 129 | + $this->output['memoryTotals'] = $memoryTotals; |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /*-------------------------------------------------------- |
@@ -134,24 +134,24 @@ discard block |
||
| 134 | 134 | ----------------------------------------------------------*/ |
| 135 | 135 | |
| 136 | 136 | public function gatherQueryData() { |
| 137 | - $queryTotals = array(); |
|
| 138 | - $queryTotals['count'] = 0; |
|
| 139 | - $queryTotals['time'] = 0; |
|
| 140 | - $queries = array(); |
|
| 137 | + $queryTotals = array(); |
|
| 138 | + $queryTotals['count'] = 0; |
|
| 139 | + $queryTotals['time'] = 0; |
|
| 140 | + $queries = array(); |
|
| 141 | 141 | |
| 142 | - if($this->db != '') { |
|
| 143 | - $queryTotals['count'] += $this->db->queryCount; |
|
| 144 | - foreach($this->db->queries as $query) { |
|
| 145 | - $query = $this->attemptToExplainQuery($query); |
|
| 146 | - $queryTotals['time'] += $query['time']; |
|
| 147 | - $query['time'] = $this->getReadableTime($query['time']); |
|
| 148 | - $queries[] = $query; |
|
| 149 | - } |
|
| 150 | - } |
|
| 142 | + if($this->db != '') { |
|
| 143 | + $queryTotals['count'] += $this->db->queryCount; |
|
| 144 | + foreach($this->db->queries as $query) { |
|
| 145 | + $query = $this->attemptToExplainQuery($query); |
|
| 146 | + $queryTotals['time'] += $query['time']; |
|
| 147 | + $query['time'] = $this->getReadableTime($query['time']); |
|
| 148 | + $queries[] = $query; |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - $queryTotals['time'] = $this->getReadableTime($queryTotals['time']); |
|
| 153 | - $this->output['queries'] = $queries; |
|
| 154 | - $this->output['queryTotals'] = $queryTotals; |
|
| 152 | + $queryTotals['time'] = $this->getReadableTime($queryTotals['time']); |
|
| 153 | + $this->output['queries'] = $queries; |
|
| 154 | + $this->output['queryTotals'] = $queryTotals; |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | /*-------------------------------------------------------- |
@@ -159,16 +159,16 @@ discard block |
||
| 159 | 159 | ----------------------------------------------------------*/ |
| 160 | 160 | |
| 161 | 161 | function attemptToExplainQuery($query) { |
| 162 | - try { |
|
| 163 | - $sql = 'EXPLAIN '.$query['sql']; |
|
| 164 | - $rs = $this->db->query($sql); |
|
| 165 | - } |
|
| 166 | - catch(Exception $e) {} |
|
| 167 | - if($rs) { |
|
| 168 | - $row = mysql_fetch_array($rs, MYSQL_ASSOC); |
|
| 169 | - $query['explain'] = $row; |
|
| 170 | - } |
|
| 171 | - return $query; |
|
| 162 | + try { |
|
| 163 | + $sql = 'EXPLAIN '.$query['sql']; |
|
| 164 | + $rs = $this->db->query($sql); |
|
| 165 | + } |
|
| 166 | + catch(Exception $e) {} |
|
| 167 | + if($rs) { |
|
| 168 | + $row = mysql_fetch_array($rs, MYSQL_ASSOC); |
|
| 169 | + $query['explain'] = $row; |
|
| 170 | + } |
|
| 171 | + return $query; |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | /*------------------------------------------- |
@@ -176,10 +176,10 @@ discard block |
||
| 176 | 176 | -------------------------------------------*/ |
| 177 | 177 | |
| 178 | 178 | public function gatherSpeedData() { |
| 179 | - $speedTotals = array(); |
|
| 180 | - $speedTotals['total'] = $this->getReadableTime((microtime(true) - $this->startTime)*1000); |
|
| 181 | - $speedTotals['allowed'] = ini_get("max_execution_time"); |
|
| 182 | - $this->output['speedTotals'] = $speedTotals; |
|
| 179 | + $speedTotals = array(); |
|
| 180 | + $speedTotals['total'] = $this->getReadableTime((microtime(true) - $this->startTime)*1000); |
|
| 181 | + $speedTotals['allowed'] = ini_get("max_execution_time"); |
|
| 182 | + $this->output['speedTotals'] = $speedTotals; |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | /*------------------------------------------- |
@@ -187,35 +187,35 @@ discard block |
||
| 187 | 187 | -------------------------------------------*/ |
| 188 | 188 | |
| 189 | 189 | public function getReadableFileSize($size, $retstring = null) { |
| 190 | - // adapted from code at http://aidanlister.com/repos/v/function.size_readable.php |
|
| 191 | - $sizes = array('bytes', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); |
|
| 190 | + // adapted from code at http://aidanlister.com/repos/v/function.size_readable.php |
|
| 191 | + $sizes = array('bytes', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); |
|
| 192 | 192 | |
| 193 | - if ($retstring === null) { $retstring = '%01.2f %s'; } |
|
| 193 | + if ($retstring === null) { $retstring = '%01.2f %s'; } |
|
| 194 | 194 | |
| 195 | - $lastsizestring = end($sizes); |
|
| 195 | + $lastsizestring = end($sizes); |
|
| 196 | 196 | |
| 197 | - foreach ($sizes as $sizestring) { |
|
| 198 | - if ($size < 1024) { break; } |
|
| 199 | - if ($sizestring != $lastsizestring) { $size /= 1024; } |
|
| 200 | - } |
|
| 201 | - if ($sizestring == $sizes[0]) { $retstring = '%01d %s'; } // Bytes aren't normally fractional |
|
| 202 | - return sprintf($retstring, $size, $sizestring); |
|
| 197 | + foreach ($sizes as $sizestring) { |
|
| 198 | + if ($size < 1024) { break; } |
|
| 199 | + if ($sizestring != $lastsizestring) { $size /= 1024; } |
|
| 200 | + } |
|
| 201 | + if ($sizestring == $sizes[0]) { $retstring = '%01d %s'; } // Bytes aren't normally fractional |
|
| 202 | + return sprintf($retstring, $size, $sizestring); |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | public function getReadableTime($time) { |
| 206 | - $ret = $time; |
|
| 207 | - $formatter = 0; |
|
| 208 | - $formats = array('ms', 's', 'm'); |
|
| 209 | - if($time >= 1000 && $time < 60000) { |
|
| 210 | - $formatter = 1; |
|
| 211 | - $ret = ($time / 1000); |
|
| 212 | - } |
|
| 213 | - if($time >= 60000) { |
|
| 214 | - $formatter = 2; |
|
| 215 | - $ret = ($time / 1000) / 60; |
|
| 216 | - } |
|
| 217 | - $ret = number_format($ret,3,'.','') . ' ' . $formats[$formatter]; |
|
| 218 | - return $ret; |
|
| 206 | + $ret = $time; |
|
| 207 | + $formatter = 0; |
|
| 208 | + $formats = array('ms', 's', 'm'); |
|
| 209 | + if($time >= 1000 && $time < 60000) { |
|
| 210 | + $formatter = 1; |
|
| 211 | + $ret = ($time / 1000); |
|
| 212 | + } |
|
| 213 | + if($time >= 60000) { |
|
| 214 | + $formatter = 2; |
|
| 215 | + $ret = ($time / 1000) / 60; |
|
| 216 | + } |
|
| 217 | + $ret = number_format($ret,3,'.','') . ' ' . $formats[$formatter]; |
|
| 218 | + return $ret; |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | /*--------------------------------------------------------- |
@@ -223,14 +223,14 @@ discard block |
||
| 223 | 223 | -----------------------------------------------------------*/ |
| 224 | 224 | |
| 225 | 225 | public function display($db = '', $master_db = '') { |
| 226 | - $this->db = $db; |
|
| 227 | - $this->master_db = $master_db; |
|
| 228 | - $this->gatherConsoleData(); |
|
| 229 | - $this->gatherFileData(); |
|
| 230 | - $this->gatherMemoryData(); |
|
| 231 | - $this->gatherQueryData(); |
|
| 232 | - $this->gatherSpeedData(); |
|
| 233 | - $display = new displayPqp(); |
|
| 234 | - $display($this->output); |
|
| 226 | + $this->db = $db; |
|
| 227 | + $this->master_db = $master_db; |
|
| 228 | + $this->gatherConsoleData(); |
|
| 229 | + $this->gatherFileData(); |
|
| 230 | + $this->gatherMemoryData(); |
|
| 231 | + $this->gatherQueryData(); |
|
| 232 | + $this->gatherSpeedData(); |
|
| 233 | + $display = new displayPqp(); |
|
| 234 | + $display($this->output); |
|
| 235 | 235 | } |
| 236 | 236 | } |
@@ -51,15 +51,15 @@ discard block |
||
| 51 | 51 | 'speed' => 0 |
| 52 | 52 | )); |
| 53 | 53 | $logs = $this->console->getLogs(); |
| 54 | - foreach($logs as $log) { |
|
| 55 | - if($log['type'] == 'log') { |
|
| 54 | + foreach ($logs as $log) { |
|
| 55 | + if ($log['type'] == 'log') { |
|
| 56 | 56 | $message = array( |
| 57 | 57 | 'data' => print_r($log['data'], true), |
| 58 | 58 | 'type' => 'log' |
| 59 | 59 | ); |
| 60 | 60 | $console['totals']['log']++; |
| 61 | 61 | } |
| 62 | - elseif($log['type'] == 'memory') { |
|
| 62 | + elseif ($log['type'] == 'memory') { |
|
| 63 | 63 | $message = array( |
| 64 | 64 | 'name' => $log['name'], |
| 65 | 65 | 'data_type' => $log['data_type'], |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | ); |
| 69 | 69 | $console['totals']['memory']++; |
| 70 | 70 | } |
| 71 | - elseif($log['type'] == 'speed') { |
|
| 71 | + elseif ($log['type'] == 'speed') { |
|
| 72 | 72 | $message = array( |
| 73 | 73 | 'name' => $log['name'], |
| 74 | 74 | 'data' => $this->getReadableTime(($log['data'] - $this->startTime) * 1000), |
@@ -102,14 +102,14 @@ discard block |
||
| 102 | 102 | "largest" => 0, |
| 103 | 103 | ); |
| 104 | 104 | |
| 105 | - foreach($files as $file) { |
|
| 105 | + foreach ($files as $file) { |
|
| 106 | 106 | $size = filesize($file); |
| 107 | 107 | $fileList[] = array( |
| 108 | 108 | 'name' => $file, |
| 109 | 109 | 'size' => $this->getReadableFileSize($size) |
| 110 | 110 | ); |
| 111 | 111 | $fileTotals['size'] += $size; |
| 112 | - if($size > $fileTotals['largest']) $fileTotals['largest'] = $size; |
|
| 112 | + if ($size > $fileTotals['largest']) $fileTotals['largest'] = $size; |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | $fileTotals['size'] = $this->getReadableFileSize($fileTotals['size']); |
@@ -139,9 +139,9 @@ discard block |
||
| 139 | 139 | $queryTotals['time'] = 0; |
| 140 | 140 | $queries = array(); |
| 141 | 141 | |
| 142 | - if($this->db != '') { |
|
| 142 | + if ($this->db != '') { |
|
| 143 | 143 | $queryTotals['count'] += $this->db->queryCount; |
| 144 | - foreach($this->db->queries as $query) { |
|
| 144 | + foreach ($this->db->queries as $query) { |
|
| 145 | 145 | $query = $this->attemptToExplainQuery($query); |
| 146 | 146 | $queryTotals['time'] += $query['time']; |
| 147 | 147 | $query['time'] = $this->getReadableTime($query['time']); |
@@ -163,8 +163,8 @@ discard block |
||
| 163 | 163 | $sql = 'EXPLAIN '.$query['sql']; |
| 164 | 164 | $rs = $this->db->query($sql); |
| 165 | 165 | } |
| 166 | - catch(Exception $e) {} |
|
| 167 | - if($rs) { |
|
| 166 | + catch (Exception $e) {} |
|
| 167 | + if ($rs) { |
|
| 168 | 168 | $row = mysql_fetch_array($rs, MYSQL_ASSOC); |
| 169 | 169 | $query['explain'] = $row; |
| 170 | 170 | } |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | |
| 178 | 178 | public function gatherSpeedData() { |
| 179 | 179 | $speedTotals = array(); |
| 180 | - $speedTotals['total'] = $this->getReadableTime((microtime(true) - $this->startTime)*1000); |
|
| 180 | + $speedTotals['total'] = $this->getReadableTime((microtime(true) - $this->startTime) * 1000); |
|
| 181 | 181 | $speedTotals['allowed'] = ini_get("max_execution_time"); |
| 182 | 182 | $this->output['speedTotals'] = $speedTotals; |
| 183 | 183 | } |
@@ -206,15 +206,15 @@ discard block |
||
| 206 | 206 | $ret = $time; |
| 207 | 207 | $formatter = 0; |
| 208 | 208 | $formats = array('ms', 's', 'm'); |
| 209 | - if($time >= 1000 && $time < 60000) { |
|
| 209 | + if ($time >= 1000 && $time < 60000) { |
|
| 210 | 210 | $formatter = 1; |
| 211 | 211 | $ret = ($time / 1000); |
| 212 | 212 | } |
| 213 | - if($time >= 60000) { |
|
| 213 | + if ($time >= 60000) { |
|
| 214 | 214 | $formatter = 2; |
| 215 | 215 | $ret = ($time / 1000) / 60; |
| 216 | 216 | } |
| 217 | - $ret = number_format($ret,3,'.','') . ' ' . $formats[$formatter]; |
|
| 217 | + $ret = number_format($ret, 3, '.', '').' '.$formats[$formatter]; |
|
| 218 | 218 | return $ret; |
| 219 | 219 | } |
| 220 | 220 | |
@@ -6,18 +6,18 @@ |
||
| 6 | 6 | class PhpQuickProfilerTest extends PHPUnit_Framework_TestCase |
| 7 | 7 | { |
| 8 | 8 | |
| 9 | - public function __construct() |
|
| 10 | - { |
|
| 11 | - } |
|
| 9 | + public function __construct() |
|
| 10 | + { |
|
| 11 | + } |
|
| 12 | 12 | |
| 13 | - public function testConstruct() |
|
| 14 | - { |
|
| 15 | - $console = new Console(); |
|
| 16 | - $startTime = microtime(true); |
|
| 13 | + public function testConstruct() |
|
| 14 | + { |
|
| 15 | + $console = new Console(); |
|
| 16 | + $startTime = microtime(true); |
|
| 17 | 17 | |
| 18 | - $profiler = new PhpQuickProfiler($console, $startTime); |
|
| 18 | + $profiler = new PhpQuickProfiler($console, $startTime); |
|
| 19 | 19 | |
| 20 | - $this->assertAttributeSame($console, 'console', $profiler); |
|
| 21 | - $this->assertAttributeEquals($startTime, 'startTime', $profiler); |
|
| 22 | - } |
|
| 20 | + $this->assertAttributeSame($console, 'console', $profiler); |
|
| 21 | + $this->assertAttributeEquals($startTime, 'startTime', $profiler); |
|
| 22 | + } |
|
| 23 | 23 | } |
@@ -20,8 +20,8 @@ |
||
| 20 | 20 | class displayPqp |
| 21 | 21 | { |
| 22 | 22 | |
| 23 | - public function __invoke($output) |
|
| 24 | - { |
|
| 23 | + public function __invoke($output) |
|
| 24 | + { |
|
| 25 | 25 | |
| 26 | 26 | $css = file_get_contents(__DIR__ . '/../css/pQp.css'); |
| 27 | 27 | |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | public function __invoke($output) |
| 24 | 24 | { |
| 25 | 25 | |
| 26 | -$css = file_get_contents(__DIR__ . '/../css/pQp.css'); |
|
| 26 | +$css = file_get_contents(__DIR__.'/../css/pQp.css'); |
|
| 27 | 27 | |
| 28 | 28 | echo <<<JAVASCRIPT |
| 29 | 29 | <!-- JavaScript --> |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | |
| 168 | 168 | echo '<div id="pqp-console" class="pqp-box">'; |
| 169 | 169 | |
| 170 | -if($logCount == 0) { |
|
| 170 | +if ($logCount == 0) { |
|
| 171 | 171 | echo '<h3>This panel has no log items.</h3>'; |
| 172 | 172 | } |
| 173 | 173 | else { |
@@ -185,25 +185,25 @@ discard block |
||
| 185 | 185 | <table class="main" cellspacing="0">'; |
| 186 | 186 | |
| 187 | 187 | $class = ''; |
| 188 | - foreach($output['logs']['console']['messages'] as $log) { |
|
| 188 | + foreach ($output['logs']['console']['messages'] as $log) { |
|
| 189 | 189 | echo '<tr class="log-'.$log['type'].'"> |
| 190 | 190 | <td class="type">'.$log['type'].'</td> |
| 191 | 191 | <td class="'.$class.'">'; |
| 192 | - if($log['type'] == 'log') { |
|
| 192 | + if ($log['type'] == 'log') { |
|
| 193 | 193 | echo '<div><pre>'.$log['data'].'</pre></div>'; |
| 194 | 194 | } |
| 195 | - elseif($log['type'] == 'memory') { |
|
| 195 | + elseif ($log['type'] == 'memory') { |
|
| 196 | 196 | echo '<div><pre>'.$log['data'].'</pre> <em>'.$log['data_type'].'</em>: '.$log['name'].' </div>'; |
| 197 | 197 | } |
| 198 | - elseif($log['type'] == 'speed') { |
|
| 198 | + elseif ($log['type'] == 'speed') { |
|
| 199 | 199 | echo '<div><pre>'.$log['data'].'</pre> <em>'.$log['name'].'</em></div>'; |
| 200 | 200 | } |
| 201 | - elseif($log['type'] == 'error') { |
|
| 201 | + elseif ($log['type'] == 'error') { |
|
| 202 | 202 | echo '<div><em>Line '.$log['line'].'</em> : '.$log['data'].' <pre>'.$log['file'].'</pre></div>'; |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | echo '</td></tr>'; |
| 206 | - if($class == '') $class = 'alt'; |
|
| 206 | + if ($class == '') $class = 'alt'; |
|
| 207 | 207 | else $class = ''; |
| 208 | 208 | } |
| 209 | 209 | |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | |
| 215 | 215 | echo '<div id="pqp-speed" class="pqp-box">'; |
| 216 | 216 | |
| 217 | -if($output['logs']['speedCount'] == 0) { |
|
| 217 | +if ($output['logs']['speedCount'] == 0) { |
|
| 218 | 218 | echo '<h3>This panel has no log items.</h3>'; |
| 219 | 219 | } |
| 220 | 220 | else { |
@@ -225,13 +225,13 @@ discard block |
||
| 225 | 225 | <table class="main" cellspacing="0">'; |
| 226 | 226 | |
| 227 | 227 | $class = ''; |
| 228 | - foreach($output['logs']['console'] as $log) { |
|
| 229 | - if($log['type'] == 'speed') { |
|
| 228 | + foreach ($output['logs']['console'] as $log) { |
|
| 229 | + if ($log['type'] == 'speed') { |
|
| 230 | 230 | echo '<tr class="log-'.$log['type'].'"> |
| 231 | 231 | <td class="'.$class.'">'; |
| 232 | 232 | echo '<div><pre>'.$log['data'].'</pre> <em>'.$log['name'].'</em></div>'; |
| 233 | 233 | echo '</td></tr>'; |
| 234 | - if($class == '') $class = 'alt'; |
|
| 234 | + if ($class == '') $class = 'alt'; |
|
| 235 | 235 | else $class = ''; |
| 236 | 236 | } |
| 237 | 237 | } |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | |
| 244 | 244 | echo '<div id="pqp-queries" class="pqp-box">'; |
| 245 | 245 | |
| 246 | -if($output['queryTotals']['count'] == 0) { |
|
| 246 | +if ($output['queryTotals']['count'] == 0) { |
|
| 247 | 247 | echo '<h3>This panel has no log items.</h3>'; |
| 248 | 248 | } |
| 249 | 249 | else { |
@@ -255,10 +255,10 @@ discard block |
||
| 255 | 255 | <table class="main" cellspacing="0">'; |
| 256 | 256 | |
| 257 | 257 | $class = ''; |
| 258 | - foreach($output['queries'] as $query) { |
|
| 258 | + foreach ($output['queries'] as $query) { |
|
| 259 | 259 | echo '<tr> |
| 260 | 260 | <td class="'.$class.'">'.$query['sql']; |
| 261 | - if($query['explain']) { |
|
| 261 | + if ($query['explain']) { |
|
| 262 | 262 | echo '<em> |
| 263 | 263 | Possible keys: <b>'.$query['explain']['possible_keys'].'</b> · |
| 264 | 264 | Key Used: <b>'.$query['explain']['key'].'</b> · |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | </em>'; |
| 269 | 269 | } |
| 270 | 270 | echo '</td></tr>'; |
| 271 | - if($class == '') $class = 'alt'; |
|
| 271 | + if ($class == '') $class = 'alt'; |
|
| 272 | 272 | else $class = ''; |
| 273 | 273 | } |
| 274 | 274 | |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | |
| 280 | 280 | echo '<div id="pqp-memory" class="pqp-box">'; |
| 281 | 281 | |
| 282 | -if($output['logs']['memoryCount'] == 0) { |
|
| 282 | +if ($output['logs']['memoryCount'] == 0) { |
|
| 283 | 283 | echo '<h3>This panel has no log items.</h3>'; |
| 284 | 284 | } |
| 285 | 285 | else { |
@@ -290,12 +290,12 @@ discard block |
||
| 290 | 290 | <table class="main" cellspacing="0">'; |
| 291 | 291 | |
| 292 | 292 | $class = ''; |
| 293 | - foreach($output['logs']['console'] as $log) { |
|
| 294 | - if($log['type'] == 'memory') { |
|
| 293 | + foreach ($output['logs']['console'] as $log) { |
|
| 294 | + if ($log['type'] == 'memory') { |
|
| 295 | 295 | echo '<tr class="log-'.$log['type'].'">'; |
| 296 | 296 | echo '<td class="'.$class.'"><b>'.$log['data'].'</b> <em>'.$log['dataType'].'</em>: '.$log['name'].'</td>'; |
| 297 | 297 | echo '</tr>'; |
| 298 | - if($class == '') $class = 'alt'; |
|
| 298 | + if ($class == '') $class = 'alt'; |
|
| 299 | 299 | else $class = ''; |
| 300 | 300 | } |
| 301 | 301 | } |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | |
| 308 | 308 | echo '<div id="pqp-files" class="pqp-box">'; |
| 309 | 309 | |
| 310 | -if($output['fileTotals']['count'] == 0) { |
|
| 310 | +if ($output['fileTotals']['count'] == 0) { |
|
| 311 | 311 | echo '<h3>This panel has no log items.</h3>'; |
| 312 | 312 | } |
| 313 | 313 | else { |
@@ -318,10 +318,10 @@ discard block |
||
| 318 | 318 | </table> |
| 319 | 319 | <table class="main" cellspacing="0">'; |
| 320 | 320 | |
| 321 | - $class =''; |
|
| 322 | - foreach($output['files'] as $file) { |
|
| 321 | + $class = ''; |
|
| 322 | + foreach ($output['files'] as $file) { |
|
| 323 | 323 | echo '<tr><td class="'.$class.'"><b>'.$file['size'].'</b> '.$file['name'].'</td></tr>'; |
| 324 | - if($class == '') $class = 'alt'; |
|
| 324 | + if ($class == '') $class = 'alt'; |
|
| 325 | 325 | else $class = ''; |
| 326 | 326 | } |
| 327 | 327 | |
@@ -167,8 +167,7 @@ discard block |
||
| 167 | 167 | |
| 168 | 168 | if($logCount == 0) { |
| 169 | 169 | echo '<h3>This panel has no log items.</h3>'; |
| 170 | -} |
|
| 171 | -else { |
|
| 170 | +} else { |
|
| 172 | 171 | echo '<table class="side" cellspacing="0"> |
| 173 | 172 | <tr> |
| 174 | 173 | <td class="alt1"><var>'.$output['logs']['logCount'].'</var><h4>Logs</h4></td> |
@@ -188,20 +187,20 @@ discard block |
||
| 188 | 187 | <td class="'.$class.'">'; |
| 189 | 188 | if($log['type'] == 'log') { |
| 190 | 189 | echo '<div><pre>'.$log['data'].'</pre></div>'; |
| 191 | - } |
|
| 192 | - elseif($log['type'] == 'memory') { |
|
| 190 | + } elseif($log['type'] == 'memory') { |
|
| 193 | 191 | echo '<div><pre>'.$log['data'].'</pre> <em>'.$log['dataType'].'</em>: '.$log['name'].' </div>'; |
| 194 | - } |
|
| 195 | - elseif($log['type'] == 'speed') { |
|
| 192 | + } elseif($log['type'] == 'speed') { |
|
| 196 | 193 | echo '<div><pre>'.$log['data'].'</pre> <em>'.$log['name'].'</em></div>'; |
| 197 | - } |
|
| 198 | - elseif($log['type'] == 'error') { |
|
| 194 | + } elseif($log['type'] == 'error') { |
|
| 199 | 195 | echo '<div><em>Line '.$log['line'].'</em> : '.$log['data'].' <pre>'.$log['file'].'</pre></div>'; |
| 200 | 196 | } |
| 201 | 197 | |
| 202 | 198 | echo '</td></tr>'; |
| 203 | - if($class == '') $class = 'alt'; |
|
| 204 | - else $class = ''; |
|
| 199 | + if($class == '') { |
|
| 200 | + $class = 'alt'; |
|
| 201 | + } else { |
|
| 202 | + $class = ''; |
|
| 203 | + } |
|
| 205 | 204 | } |
| 206 | 205 | |
| 207 | 206 | echo '</table>'; |
@@ -213,8 +212,7 @@ discard block |
||
| 213 | 212 | |
| 214 | 213 | if($output['logs']['speedCount'] == 0) { |
| 215 | 214 | echo '<h3>This panel has no log items.</h3>'; |
| 216 | -} |
|
| 217 | -else { |
|
| 215 | +} else { |
|
| 218 | 216 | echo '<table class="side" cellspacing="0"> |
| 219 | 217 | <tr><td><var>'.$output['speedTotals']['total'].'</var><h4>Load Time</h4></td></tr> |
| 220 | 218 | <tr><td class="alt"><var>'.$output['speedTotals']['allowed'].'</var> <h4>Max Execution Time</h4></td></tr> |
@@ -228,8 +226,11 @@ discard block |
||
| 228 | 226 | <td class="'.$class.'">'; |
| 229 | 227 | echo '<div><pre>'.$log['data'].'</pre> <em>'.$log['name'].'</em></div>'; |
| 230 | 228 | echo '</td></tr>'; |
| 231 | - if($class == '') $class = 'alt'; |
|
| 232 | - else $class = ''; |
|
| 229 | + if($class == '') { |
|
| 230 | + $class = 'alt'; |
|
| 231 | + } else { |
|
| 232 | + $class = ''; |
|
| 233 | + } |
|
| 233 | 234 | } |
| 234 | 235 | } |
| 235 | 236 | |
@@ -242,8 +243,7 @@ discard block |
||
| 242 | 243 | |
| 243 | 244 | if($output['queryTotals']['count'] == 0) { |
| 244 | 245 | echo '<h3>This panel has no log items.</h3>'; |
| 245 | -} |
|
| 246 | -else { |
|
| 246 | +} else { |
|
| 247 | 247 | echo '<table class="side" cellspacing="0"> |
| 248 | 248 | <tr><td><var>'.$output['queryTotals']['count'].'</var><h4>Total Queries</h4></td></tr> |
| 249 | 249 | <tr><td class="alt"><var>'.$output['queryTotals']['time'].'</var> <h4>Total Time</h4></td></tr> |
@@ -265,8 +265,11 @@ discard block |
||
| 265 | 265 | </em>'; |
| 266 | 266 | } |
| 267 | 267 | echo '</td></tr>'; |
| 268 | - if($class == '') $class = 'alt'; |
|
| 269 | - else $class = ''; |
|
| 268 | + if($class == '') { |
|
| 269 | + $class = 'alt'; |
|
| 270 | + } else { |
|
| 271 | + $class = ''; |
|
| 272 | + } |
|
| 270 | 273 | } |
| 271 | 274 | |
| 272 | 275 | echo '</table>'; |
@@ -278,8 +281,7 @@ discard block |
||
| 278 | 281 | |
| 279 | 282 | if($output['logs']['memoryCount'] == 0) { |
| 280 | 283 | echo '<h3>This panel has no log items.</h3>'; |
| 281 | -} |
|
| 282 | -else { |
|
| 284 | +} else { |
|
| 283 | 285 | echo '<table class="side" cellspacing="0"> |
| 284 | 286 | <tr><td><var>'.$output['memoryTotals']['used'].'</var><h4>Used Memory</h4></td></tr> |
| 285 | 287 | <tr><td class="alt"><var>'.$output['memoryTotals']['total'].'</var> <h4>Total Available</h4></td></tr> |
@@ -292,8 +294,11 @@ discard block |
||
| 292 | 294 | echo '<tr class="log-'.$log['type'].'">'; |
| 293 | 295 | echo '<td class="'.$class.'"><b>'.$log['data'].'</b> <em>'.$log['dataType'].'</em>: '.$log['name'].'</td>'; |
| 294 | 296 | echo '</tr>'; |
| 295 | - if($class == '') $class = 'alt'; |
|
| 296 | - else $class = ''; |
|
| 297 | + if($class == '') { |
|
| 298 | + $class = 'alt'; |
|
| 299 | + } else { |
|
| 300 | + $class = ''; |
|
| 301 | + } |
|
| 297 | 302 | } |
| 298 | 303 | } |
| 299 | 304 | |
@@ -306,8 +311,7 @@ discard block |
||
| 306 | 311 | |
| 307 | 312 | if($output['fileTotals']['count'] == 0) { |
| 308 | 313 | echo '<h3>This panel has no log items.</h3>'; |
| 309 | -} |
|
| 310 | -else { |
|
| 314 | +} else { |
|
| 311 | 315 | echo '<table class="side" cellspacing="0"> |
| 312 | 316 | <tr><td><var>'.$output['fileTotals']['count'].'</var><h4>Total Files</h4></td></tr> |
| 313 | 317 | <tr><td class="alt"><var>'.$output['fileTotals']['size'].'</var> <h4>Total Size</h4></td></tr> |
@@ -318,8 +322,11 @@ discard block |
||
| 318 | 322 | $class =''; |
| 319 | 323 | foreach($output['files'] as $file) { |
| 320 | 324 | echo '<tr><td class="'.$class.'"><b>'.$file['size'].'</b> '.$file['name'].'</td></tr>'; |
| 321 | - if($class == '') $class = 'alt'; |
|
| 322 | - else $class = ''; |
|
| 325 | + if($class == '') { |
|
| 326 | + $class = 'alt'; |
|
| 327 | + } else { |
|
| 328 | + $class = ''; |
|
| 329 | + } |
|
| 323 | 330 | } |
| 324 | 331 | |
| 325 | 332 | echo '</table>'; |