@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | $handle = @fopen($configuration_path, 'r'); |
| 9 | 9 | if ($handle === false) { |
| 10 | - throw new RuntimeException("Could not load configuration"); |
|
| 10 | + throw new RuntimeException("Could not load configuration"); |
|
| 11 | 11 | } |
| 12 | 12 | $configuration = fread($handle, filesize($configuration_path)); |
| 13 | 13 | fclose($handle); |
@@ -15,40 +15,40 @@ discard block |
||
| 15 | 15 | $configuration = json_decode($configuration); |
| 16 | 16 | $last_json_error = json_last_error(); |
| 17 | 17 | if ($last_json_error !== JSON_ERROR_NONE) { |
| 18 | - throw new RuntimeException("Could not parse configuration - JSON error detected"); |
|
| 18 | + throw new RuntimeException("Could not parse configuration - JSON error detected"); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | // configure the db connections holder |
| 22 | 22 | $db_connections = new Aura\Sql\ConnectionLocator(); |
| 23 | 23 | $db_connections->setDefault(function () use ($configuration) { |
| 24 | - $connection = $configuration->database->slave; |
|
| 25 | - return new Aura\Sql\ExtendedPdo( |
|
| 26 | - "mysql:host={$connection->host}", |
|
| 27 | - $connection->user, |
|
| 28 | - $connection->password |
|
| 29 | - ); |
|
| 24 | + $connection = $configuration->database->slave; |
|
| 25 | + return new Aura\Sql\ExtendedPdo( |
|
| 26 | + "mysql:host={$connection->host}", |
|
| 27 | + $connection->user, |
|
| 28 | + $connection->password |
|
| 29 | + ); |
|
| 30 | 30 | }); |
| 31 | 31 | $db_connections->setWrite('master', function () use ($configuration) { |
| 32 | - $connection = $configuration->database->master; |
|
| 33 | - return new Aura\Sql\ExtendedPdo( |
|
| 34 | - "mysql:host={$connection->host}", |
|
| 35 | - $connection->user, |
|
| 36 | - $connection->password |
|
| 37 | - ); |
|
| 32 | + $connection = $configuration->database->master; |
|
| 33 | + return new Aura\Sql\ExtendedPdo( |
|
| 34 | + "mysql:host={$connection->host}", |
|
| 35 | + $connection->user, |
|
| 36 | + $connection->password |
|
| 37 | + ); |
|
| 38 | 38 | }); |
| 39 | 39 | $db_connections->setRead('slave', function () use ($configuration) { |
| 40 | - $connection = $configuration->database->slave; |
|
| 41 | - $pdo = new Aura\Sql\ExtendedPdo( |
|
| 42 | - "mysql:host={$connection->host}", |
|
| 43 | - $connection->user, |
|
| 44 | - $connection->password |
|
| 45 | - ); |
|
| 46 | - |
|
| 47 | - $profiler = new Aura\Sql\Profiler(); |
|
| 48 | - $profiler->setActive(true); |
|
| 49 | - $pdo->setProfiler($profiler); |
|
| 50 | - |
|
| 51 | - return $pdo; |
|
| 40 | + $connection = $configuration->database->slave; |
|
| 41 | + $pdo = new Aura\Sql\ExtendedPdo( |
|
| 42 | + "mysql:host={$connection->host}", |
|
| 43 | + $connection->user, |
|
| 44 | + $connection->password |
|
| 45 | + ); |
|
| 46 | + |
|
| 47 | + $profiler = new Aura\Sql\Profiler(); |
|
| 48 | + $profiler->setActive(true); |
|
| 49 | + $pdo->setProfiler($profiler); |
|
| 50 | + |
|
| 51 | + return $pdo; |
|
| 52 | 52 | }); |
| 53 | 53 | |
| 54 | 54 | // setup the service locator |
@@ -18,8 +18,8 @@ discard block |
||
| 18 | 18 | private function __construct() |
| 19 | 19 | {
|
| 20 | 20 | $this->console = new Console(); |
| 21 | - $this->profiler = new PhpQuickProfiler(); |
|
| 22 | - $this->profiler->setConsole($this->console); |
|
| 21 | + $this->profiler = new PhpQuickProfiler(); |
|
| 22 | + $this->profiler->setConsole($this->console); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | public static function instance() |
@@ -82,25 +82,25 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | public static function display() |
| 84 | 84 | {
|
| 85 | - if ($_COOKIE['debugger'] == 'display' && self::instance()->display) {
|
|
| 86 | - $pdo = ''; |
|
| 87 | - if (!empty($pdo)) {
|
|
| 88 | - $profiles = $pdo->getProfiler()->getProfiles(); |
|
| 89 | - $profiles = array_filter($profiles, function ($profile) {
|
|
| 90 | - return $profile['function'] == 'perform'; |
|
| 91 | - }); |
|
| 92 | - $profiles = array_map(function ($profile) {
|
|
| 93 | - return array( |
|
| 94 | - 'sql' => $profile['statement'], |
|
| 95 | - 'parameters' => $profile['bind_values'], |
|
| 96 | - 'time' => $profile['duration'] |
|
| 97 | - ); |
|
| 98 | - }, $profiles); |
|
| 99 | - self::instance()->profiler->setProfiledQueries($profiles); |
|
| 100 | - } |
|
| 101 | - self::instance()->profiler->setDisplay(new Particletree\Pqp\Display()); |
|
| 102 | - self::instance()->profiler->display($pdo); |
|
| 103 | - } |
|
| 85 | + if ($_COOKIE['debugger'] == 'display' && self::instance()->display) {
|
|
| 86 | + $pdo = ''; |
|
| 87 | + if (!empty($pdo)) {
|
|
| 88 | + $profiles = $pdo->getProfiler()->getProfiles(); |
|
| 89 | + $profiles = array_filter($profiles, function ($profile) {
|
|
| 90 | + return $profile['function'] == 'perform'; |
|
| 91 | + }); |
|
| 92 | + $profiles = array_map(function ($profile) {
|
|
| 93 | + return array( |
|
| 94 | + 'sql' => $profile['statement'], |
|
| 95 | + 'parameters' => $profile['bind_values'], |
|
| 96 | + 'time' => $profile['duration'] |
|
| 97 | + ); |
|
| 98 | + }, $profiles); |
|
| 99 | + self::instance()->profiler->setProfiledQueries($profiles); |
|
| 100 | + } |
|
| 101 | + self::instance()->profiler->setDisplay(new Particletree\Pqp\Display()); |
|
| 102 | + self::instance()->profiler->display($pdo); |
|
| 103 | + } |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | } |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | private static $UNKNOWN_ERROR_FILE = 'Unknown File'; |
| 10 | 10 | private static $UNKNOWN_ERROR_LINE = 'Unknown Line'; |
| 11 | - private static $UNKNOWN_ERROR_CONTEXT = 'Unknown Context'; |
|
| 11 | + private static $UNKNOWN_ERROR_CONTEXT = 'Unknown Context'; |
|
| 12 | 12 | |
| 13 | 13 | private $profiler; |
| 14 | 14 | private $display = true; |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | public static function instance() |
| 26 | 26 | {
|
| 27 | - if(!isset(self::$instance)) |
|
| 27 | + if (!isset(self::$instance)) |
|
| 28 | 28 | self::$instance = new Debugger(); |
| 29 | 29 | return self::$instance; |
| 30 | 30 | } |
@@ -52,11 +52,11 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | public static function internal_error($code, $string, $file = null, $line = null, $context = null) |
| 54 | 54 | {
|
| 55 | - if($file == null) |
|
| 55 | + if ($file == null) |
|
| 56 | 56 | $file = self::$UNKNOWN_ERROR_FILE; |
| 57 | - if($line == null) |
|
| 57 | + if ($line == null) |
|
| 58 | 58 | $line = self::$UNKNOWN_ERROR_LINE; |
| 59 | - if($context == null) |
|
| 59 | + if ($context == null) |
|
| 60 | 60 | $context = self::$UNKNOWN_ERROR_CONTEXT; |
| 61 | 61 | |
| 62 | 62 | self::instance()->console->logError(new Exception($string), "{$string}... TYPE: {$code}");
|
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | {
|
| 69 | 69 | $error = error_get_last(); |
| 70 | 70 | |
| 71 | - if(isset($error)) |
|
| 71 | + if (isset($error)) |
|
| 72 | 72 | self::internal_error($error['type'], $error['message'], $error['file'], $error['line']); |
| 73 | 73 | |
| 74 | 74 | self::display(); |
@@ -86,10 +86,10 @@ discard block |
||
| 86 | 86 | $pdo = ''; |
| 87 | 87 | if (!empty($pdo)) {
|
| 88 | 88 | $profiles = $pdo->getProfiler()->getProfiles(); |
| 89 | - $profiles = array_filter($profiles, function ($profile) {
|
|
| 89 | + $profiles = array_filter($profiles, function($profile) {
|
|
| 90 | 90 | return $profile['function'] == 'perform'; |
| 91 | 91 | }); |
| 92 | - $profiles = array_map(function ($profile) {
|
|
| 92 | + $profiles = array_map(function($profile) {
|
|
| 93 | 93 | return array( |
| 94 | 94 | 'sql' => $profile['statement'], |
| 95 | 95 | 'parameters' => $profile['bind_values'], |