Completed
Push — master ( 5bed8f...b71929 )
by Jacob
04:00
created
bootstrap.php 2 patches
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 
16 16
 $handle = @fopen($config_path, 'r');
17 17
 if ($handle === false) {
18
-    throw new RuntimeException("Could not load config");
18
+	throw new RuntimeException("Could not load config");
19 19
 }
20 20
 $config = fread($handle, filesize($config_path));
21 21
 fclose($handle);
@@ -23,71 +23,71 @@  discard block
 block discarded – undo
23 23
 $config = json_decode($config);
24 24
 $last_json_error = json_last_error();
25 25
 if ($last_json_error !== JSON_ERROR_NONE) {
26
-    throw new RuntimeException("Could not parse config - JSON error detected");
26
+	throw new RuntimeException("Could not parse config - JSON error detected");
27 27
 }
28 28
 $container['config'] = $config;
29 29
 
30 30
 // timezones are fun
31 31
 date_default_timezone_set('America/Phoenix'); // todo - belongs in configuration
32 32
 $container['default_timezone'] = function ($c) {
33
-    return new DateTimeZone('America/Phoenix');
33
+	return new DateTimeZone('America/Phoenix');
34 34
 };
35 35
 
36 36
 
37 37
 // configure the db connections holder
38 38
 $db_connections = new Aura\Sql\ConnectionLocator();
39 39
 $db_connections->setDefault(function () use ($config) {
40
-    $connection = $config->database->slave;
41
-    return new Aura\Sql\ExtendedPdo(
42
-        "mysql:host={$connection->host}",
43
-        $connection->user,
44
-        $connection->password
45
-    );
40
+	$connection = $config->database->slave;
41
+	return new Aura\Sql\ExtendedPdo(
42
+		"mysql:host={$connection->host}",
43
+		$connection->user,
44
+		$connection->password
45
+	);
46 46
 });
47 47
 $db_connections->setWrite('master', function () use ($config) {
48
-    $connection = $config->database->master;
49
-    return new Aura\Sql\ExtendedPdo(
50
-        "mysql:host={$connection->host}",
51
-        $connection->user,
52
-        $connection->password
53
-    );
48
+	$connection = $config->database->master;
49
+	return new Aura\Sql\ExtendedPdo(
50
+		"mysql:host={$connection->host}",
51
+		$connection->user,
52
+		$connection->password
53
+	);
54 54
 });
55 55
 $db_connections->setRead('slave', function () use ($config) {
56
-    $connection = $config->database->slave;
57
-    $pdo = new Aura\Sql\ExtendedPdo(
58
-        "mysql:host={$connection->host}",
59
-        $connection->user,
60
-        $connection->password
61
-    );
62
-
63
-    $profiler = new Aura\Sql\Profiler();
64
-    $profiler->setActive(true);
65
-    $pdo->setProfiler($profiler);
66
-
67
-    return $pdo;
56
+	$connection = $config->database->slave;
57
+	$pdo = new Aura\Sql\ExtendedPdo(
58
+		"mysql:host={$connection->host}",
59
+		$connection->user,
60
+		$connection->password
61
+	);
62
+
63
+	$profiler = new Aura\Sql\Profiler();
64
+	$profiler->setActive(true);
65
+	$pdo->setProfiler($profiler);
66
+
67
+	return $pdo;
68 68
 });
69 69
 $container['db_connection_locator'] = $db_connections;
70 70
 
71 71
 
72 72
 // setup mail handler
73 73
 $container['mail'] = $container->factory(function ($c) {
74
-    return (new Jacobemerick\Archangel\Archangel())->setLogger($c['logger']);
74
+	return (new Jacobemerick\Archangel\Archangel())->setLogger($c['logger']);
75 75
 });
76 76
 
77 77
 
78 78
 // setup the logger
79 79
 $container['setup_logger'] = $container->protect(function ($name) use ($container) {
80
-    $logger = new Monolog\Logger($name);
80
+	$logger = new Monolog\Logger($name);
81 81
 
82
-    $logPath = __DIR__ . "/logs/{$name}.log";
83
-    $streamHandler = new Monolog\Handler\StreamHandler($logPath, Monolog\Logger::INFO);
84
-    $streamHandler->setFormatter(
85
-        new Monolog\Formatter\LineFormatter("[%datetime%] %channel%.%level_name%: %message%\n")
86
-    );
87
-    $logger->pushHandler($streamHandler);
82
+	$logPath = __DIR__ . "/logs/{$name}.log";
83
+	$streamHandler = new Monolog\Handler\StreamHandler($logPath, Monolog\Logger::INFO);
84
+	$streamHandler->setFormatter(
85
+		new Monolog\Formatter\LineFormatter("[%datetime%] %channel%.%level_name%: %message%\n")
86
+	);
87
+	$logger->pushHandler($streamHandler);
88 88
 
89
-    Monolog\ErrorHandler::register($logger);
90
-    $container['logger'] = $logger;
89
+	Monolog\ErrorHandler::register($logger);
90
+	$container['logger'] = $logger;
91 91
 });
92 92
 
93 93
 
@@ -108,30 +108,30 @@  discard block
 block discarded – undo
108 108
 
109 109
 // sets up shutdown function to display profiler
110 110
 register_shutdown_function(function () use ($container) {
111
-    if (
112
-        !isset($_COOKIE['debugger']) ||
113
-        $_COOKIE['debugger'] != 'display'
114
-    ) {
115
-        return;
116
-    }
117
-
118
-    $dbProfiles = $container['db_connection_locator']
119
-        ->getRead()
120
-        ->getProfiler()
121
-        ->getProfiles();
122
-    $dbProfiles = array_filter($dbProfiles, function ($profile) {
123
-        return $profile['function'] == 'perform';
124
-    });
125
-    $dbProfiles = array_map(function ($profile) {
126
-        return [
127
-            'sql' => trim(preg_replace('/\s+/', ' ', $profile['statement'])),
128
-            'parameters' => $profile['bind_values'],
129
-            'time' => $profile['duration'],
130
-        ];
131
-    }, $dbProfiles);
132
-    $container['profiler']->setProfiledQueries($dbProfiles);
133
-    $container['profiler']->setDisplay(new Particletree\Pqp\Display());
134
-    $container['profiler']->display($container['db_connection_locator']->getRead());
111
+	if (
112
+		!isset($_COOKIE['debugger']) ||
113
+		$_COOKIE['debugger'] != 'display'
114
+	) {
115
+		return;
116
+	}
117
+
118
+	$dbProfiles = $container['db_connection_locator']
119
+		->getRead()
120
+		->getProfiler()
121
+		->getProfiles();
122
+	$dbProfiles = array_filter($dbProfiles, function ($profile) {
123
+		return $profile['function'] == 'perform';
124
+	});
125
+	$dbProfiles = array_map(function ($profile) {
126
+		return [
127
+			'sql' => trim(preg_replace('/\s+/', ' ', $profile['statement'])),
128
+			'parameters' => $profile['bind_values'],
129
+			'time' => $profile['duration'],
130
+		];
131
+	}, $dbProfiles);
132
+	$container['profiler']->setProfiledQueries($dbProfiles);
133
+	$container['profiler']->setDisplay(new Particletree\Pqp\Display());
134
+	$container['profiler']->display($container['db_connection_locator']->getRead());
135 135
 });
136 136
 
137 137
 $container['console']->logMemory(null, 'PHP - Post-boostrap memory');
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -5,13 +5,13 @@  discard block
 block discarded – undo
5 5
 ini_set('display_errors', 0);
6 6
 
7 7
 
8
-require_once __DIR__ . '/vendor/autoload.php';
8
+require_once __DIR__.'/vendor/autoload.php';
9 9
 
10 10
 $container = new Pimple\Container();
11 11
 
12 12
 
13 13
 // load the config for the application
14
-$config_path = __DIR__ . '/config.json';
14
+$config_path = __DIR__.'/config.json';
15 15
 
16 16
 $handle = @fopen($config_path, 'r');
17 17
 if ($handle === false) {
@@ -29,14 +29,14 @@  discard block
 block discarded – undo
29 29
 
30 30
 // timezones are fun
31 31
 date_default_timezone_set('America/Phoenix'); // todo - belongs in configuration
32
-$container['default_timezone'] = function ($c) {
32
+$container['default_timezone'] = function($c) {
33 33
     return new DateTimeZone('America/Phoenix');
34 34
 };
35 35
 
36 36
 
37 37
 // configure the db connections holder
38 38
 $db_connections = new Aura\Sql\ConnectionLocator();
39
-$db_connections->setDefault(function () use ($config) {
39
+$db_connections->setDefault(function() use ($config) {
40 40
     $connection = $config->database->slave;
41 41
     return new Aura\Sql\ExtendedPdo(
42 42
         "mysql:host={$connection->host}",
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
         $connection->password
45 45
     );
46 46
 });
47
-$db_connections->setWrite('master', function () use ($config) {
47
+$db_connections->setWrite('master', function() use ($config) {
48 48
     $connection = $config->database->master;
49 49
     return new Aura\Sql\ExtendedPdo(
50 50
         "mysql:host={$connection->host}",
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
         $connection->password
53 53
     );
54 54
 });
55
-$db_connections->setRead('slave', function () use ($config) {
55
+$db_connections->setRead('slave', function() use ($config) {
56 56
     $connection = $config->database->slave;
57 57
     $pdo = new Aura\Sql\ExtendedPdo(
58 58
         "mysql:host={$connection->host}",
@@ -70,16 +70,16 @@  discard block
 block discarded – undo
70 70
 
71 71
 
72 72
 // setup mail handler
73
-$container['mail'] = $container->factory(function ($c) {
73
+$container['mail'] = $container->factory(function($c) {
74 74
     return (new Jacobemerick\Archangel\Archangel())->setLogger($c['logger']);
75 75
 });
76 76
 
77 77
 
78 78
 // setup the logger
79
-$container['setup_logger'] = $container->protect(function ($name) use ($container) {
79
+$container['setup_logger'] = $container->protect(function($name) use ($container) {
80 80
     $logger = new Monolog\Logger($name);
81 81
 
82
-    $logPath = __DIR__ . "/logs/{$name}.log";
82
+    $logPath = __DIR__."/logs/{$name}.log";
83 83
     $streamHandler = new Monolog\Handler\StreamHandler($logPath, Monolog\Logger::INFO);
84 84
     $streamHandler->setFormatter(
85 85
         new Monolog\Formatter\LineFormatter("[%datetime%] %channel%.%level_name%: %message%\n")
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 
108 108
 
109 109
 // sets up shutdown function to display profiler
110
-register_shutdown_function(function () use ($container) {
110
+register_shutdown_function(function() use ($container) {
111 111
     if (
112 112
         !isset($_COOKIE['debugger']) ||
113 113
         $_COOKIE['debugger'] != 'display'
@@ -119,10 +119,10 @@  discard block
 block discarded – undo
119 119
         ->getRead()
120 120
         ->getProfiler()
121 121
         ->getProfiles();
122
-    $dbProfiles = array_filter($dbProfiles, function ($profile) {
122
+    $dbProfiles = array_filter($dbProfiles, function($profile) {
123 123
         return $profile['function'] == 'perform';
124 124
     });
125
-    $dbProfiles = array_map(function ($profile) {
125
+    $dbProfiles = array_map(function($profile) {
126 126
         return [
127 127
             'sql' => trim(preg_replace('/\s+/', ' ', $profile['statement'])),
128 128
             'parameters' => $profile['bind_values'],
Please login to merge, or discard this patch.
controller/blog/DefaultPageController.class.inc.php 1 patch
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -18,14 +18,14 @@  discard block
 block discarded – undo
18 18
 
19 19
 	protected function set_head_data()
20 20
 	{
21
-    $this->set_head('rss_link', [
22
-      'title' => 'Jacob Emerick Blog Feed',
23
-      'url' => '/rss.xml'
24
-    ]);
25
-    $this->set_head('rss_comment_link', [
26
-      'title' => 'Jacob Emerick Blog Comment Feed',
27
-      'url' => '/rss-comments.xml'
28
-    ]);
21
+	$this->set_head('rss_link', [
22
+	  'title' => 'Jacob Emerick Blog Feed',
23
+	  'url' => '/rss.xml'
24
+	]);
25
+	$this->set_head('rss_comment_link', [
26
+	  'title' => 'Jacob Emerick Blog Comment Feed',
27
+	  'url' => '/rss-comments.xml'
28
+	]);
29 29
 		
30 30
 		$this->add_css('normalize');
31 31
 		$this->add_css('blog');
@@ -83,45 +83,45 @@  discard block
 block discarded – undo
83 83
 	final private function get_comments_for_post($post)
84 84
 	{
85 85
 		$count = CommentCollector::getCommentCountForURL(self::$BLOG_SITE_ID, $post['path']);
86
-    $count_from_service = $this->get_comments_for_post_from_service($post);
87
-
88
-    if ($count != $count_from_service) {
89
-        global $container;
90
-        $container['console']->log('Mismatch between comment service and legacy db');
91
-        $container['console']->log("{$count}, {$count_from_service} in service");
92
-    }
93
-    return $count;
94
-	}
95
-
96
-    final private function get_comments_for_post_from_service($post)
97
-    {
98
-        global $config;
99
-        $configuration = new Jacobemerick\CommentService\Configuration();
100
-        $configuration->setUsername($config->comments->user);
101
-        $configuration->setPassword($config->comments->password);
102
-        $configuration->addDefaultHeader('Content-Type', 'application/json');
103
-        $configuration->setHost($config->comments->host);
104
-        $configuration->setCurlTimeout($config->comments->timeout);
105
-
106
-        $client = new Jacobemerick\CommentService\ApiClient($configuration);
107
-        $api = new Jacobemerick\CommentService\Api\DefaultApi($client);
108
-
109
-        $start = microtime(true);
110
-        $comment_response = $api->getComments(null, null, null, 'blog.jacobemerick.com', "{$post['category']}/{$post['path']}");
111
-        $elapsed = microtime(true) - $start;
112
-        global $container;
113
-        $container['logger']->info("CommentService | Comment Count | {$elapsed}");
114
-
115
-        return count($comment_response);
116
-    }
86
+	$count_from_service = $this->get_comments_for_post_from_service($post);
87
+
88
+	if ($count != $count_from_service) {
89
+		global $container;
90
+		$container['console']->log('Mismatch between comment service and legacy db');
91
+		$container['console']->log("{$count}, {$count_from_service} in service");
92
+	}
93
+	return $count;
94
+	}
95
+
96
+	final private function get_comments_for_post_from_service($post)
97
+	{
98
+		global $config;
99
+		$configuration = new Jacobemerick\CommentService\Configuration();
100
+		$configuration->setUsername($config->comments->user);
101
+		$configuration->setPassword($config->comments->password);
102
+		$configuration->addDefaultHeader('Content-Type', 'application/json');
103
+		$configuration->setHost($config->comments->host);
104
+		$configuration->setCurlTimeout($config->comments->timeout);
105
+
106
+		$client = new Jacobemerick\CommentService\ApiClient($configuration);
107
+		$api = new Jacobemerick\CommentService\Api\DefaultApi($client);
108
+
109
+		$start = microtime(true);
110
+		$comment_response = $api->getComments(null, null, null, 'blog.jacobemerick.com', "{$post['category']}/{$post['path']}");
111
+		$elapsed = microtime(true) - $start;
112
+		global $container;
113
+		$container['logger']->info("CommentService | Comment Count | {$elapsed}");
114
+
115
+		return count($comment_response);
116
+	}
117 117
 
118 118
 	final private function get_tags_for_post($post)
119 119
 	{
120
-        global $container;
121
-        $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']);
122
-        $tag_result = $repository->getTagsForPost($post['id']);
120
+		global $container;
121
+		$repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']);
122
+		$tag_result = $repository->getTagsForPost($post['id']);
123 123
 
124
-        $tag_array = array();
124
+		$tag_array = array();
125 125
 		foreach($tag_result as $tag)
126 126
 		{
127 127
 			$tag_object = new stdclass();
@@ -155,9 +155,9 @@  discard block
 block discarded – undo
155 155
 
156 156
 	final private function get_tag_cloud()
157 157
 	{
158
-        global $container;
159
-        $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']);
160
-        $tag_result = $repository->getTagCloud();
158
+		global $container;
159
+		$repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']);
160
+		$tag_result = $repository->getTagCloud();
161 161
 		
162 162
 		$maximum_tag_count = $this->get_maximum_tag_count($tag_result);
163 163
 		
@@ -206,49 +206,49 @@  discard block
 block discarded – undo
206 206
 			$array[] = $comment_obj;
207 207
 		}
208 208
 
209
-    $comment_service_array = $this->get_comments_from_service();
210
-    if ($comment_service_array !== $array) {
211
-      global $container;
212
-      $container['console']->log('Mismatch between comment service and legacy db');
213
-      $container['console']->log($comment_service_array[0]);
214
-      $container['console']->log($array[0]);
215
-    }
209
+	$comment_service_array = $this->get_comments_from_service();
210
+	if ($comment_service_array !== $array) {
211
+	  global $container;
212
+	  $container['console']->log('Mismatch between comment service and legacy db');
213
+	  $container['console']->log($comment_service_array[0]);
214
+	  $container['console']->log($array[0]);
215
+	}
216 216
 		return $array;
217 217
 	}
218 218
 
219
-    final private function get_comments_from_service()
220
-    {
221
-        global $config;
222
-        $configuration = new Jacobemerick\CommentService\Configuration();
223
-        $configuration->setUsername($config->comments->user);
224
-        $configuration->setPassword($config->comments->password);
225
-        $configuration->addDefaultHeader('Content-Type', 'application/json');
226
-        $configuration->setHost($config->comments->host);
227
-        $configuration->setCurlTimeout($config->comments->timeout);
228
-
229
-        $client = new Jacobemerick\CommentService\ApiClient($configuration);
230
-        $api = new Jacobemerick\CommentService\Api\DefaultApi($client);
231
-
232
-        $start = microtime(true);
233
-        $comment_response = $api->getComments(1, self::$RECENT_COMMENT_COUNT, '-date', 'blog.jacobemerick.com');
234
-        $elapsed = microtime(true) - $start;
235
-        global $container;
236
-        $container['logger']->info("CommentService | Sidebar | {$elapsed}");
237
-
238
-        $array = array();
239
-        foreach($comment_response as $comment)
240
-        {
241
-            $body = $comment->getBody();
242
-            $body = Content::instance('CleanComment', $body)->activate();
243
-            $body = strip_tags($body);
244
-
245
-            $comment_obj = new stdclass();
246
-            $comment_obj->description = Content::instance('SmartTrim', $body)->activate(30);
247
-            $comment_obj->commenter = $comment->getCommenter()->getName();
248
-            $comment_obj->link = "{$comment->getUrl()}/#comment-{$comment->getId()}";
249
-            $array[] = $comment_obj;
250
-        }
251
-        return $array;
252
-    }
219
+	final private function get_comments_from_service()
220
+	{
221
+		global $config;
222
+		$configuration = new Jacobemerick\CommentService\Configuration();
223
+		$configuration->setUsername($config->comments->user);
224
+		$configuration->setPassword($config->comments->password);
225
+		$configuration->addDefaultHeader('Content-Type', 'application/json');
226
+		$configuration->setHost($config->comments->host);
227
+		$configuration->setCurlTimeout($config->comments->timeout);
228
+
229
+		$client = new Jacobemerick\CommentService\ApiClient($configuration);
230
+		$api = new Jacobemerick\CommentService\Api\DefaultApi($client);
231
+
232
+		$start = microtime(true);
233
+		$comment_response = $api->getComments(1, self::$RECENT_COMMENT_COUNT, '-date', 'blog.jacobemerick.com');
234
+		$elapsed = microtime(true) - $start;
235
+		global $container;
236
+		$container['logger']->info("CommentService | Sidebar | {$elapsed}");
237
+
238
+		$array = array();
239
+		foreach($comment_response as $comment)
240
+		{
241
+			$body = $comment->getBody();
242
+			$body = Content::instance('CleanComment', $body)->activate();
243
+			$body = strip_tags($body);
244
+
245
+			$comment_obj = new stdclass();
246
+			$comment_obj->description = Content::instance('SmartTrim', $body)->activate(30);
247
+			$comment_obj->commenter = $comment->getCommenter()->getName();
248
+			$comment_obj->link = "{$comment->getUrl()}/#comment-{$comment->getId()}";
249
+			$array[] = $comment_obj;
250
+		}
251
+		return $array;
252
+	}
253 253
 
254 254
 }
Please login to merge, or discard this patch.