Completed
Push — master ( ac298f...e13fa7 )
by Jacob
05:12 queued 13s
created
bootstrap.php 2 patches
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 
11 11
 $handle = @fopen($config_path, 'r');
12 12
 if ($handle === false) {
13
-    throw new RuntimeException("Could not load config");
13
+	throw new RuntimeException("Could not load config");
14 14
 }
15 15
 $config = fread($handle, filesize($config_path));
16 16
 fclose($handle);
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 $config = json_decode($config);
19 19
 $last_json_error = json_last_error();
20 20
 if ($last_json_error !== JSON_ERROR_NONE) {
21
-    throw new RuntimeException("Could not parse config - JSON error detected");
21
+	throw new RuntimeException("Could not parse config - JSON error detected");
22 22
 }
23 23
 $container['config'] = $config;
24 24
 
@@ -26,64 +26,64 @@  discard block
 block discarded – undo
26 26
 // timezones are fun
27 27
 date_default_timezone_set('America/Phoenix'); // todo - belongs in configuration
28 28
 $container['default_timezone'] = function ($c) {
29
-    return new DateTimeZone('America/Phoenix');
29
+	return new DateTimeZone('America/Phoenix');
30 30
 };
31 31
 
32 32
 
33 33
 // configure the db connections holder
34 34
 $db_connections = new Aura\Sql\ConnectionLocator();
35 35
 $db_connections->setDefault(function () use ($config) {
36
-    $connection = $config->database->slave;
37
-    return new Aura\Sql\ExtendedPdo(
38
-        "mysql:host={$connection->host}",
39
-        $connection->user,
40
-        $connection->password
41
-    );
36
+	$connection = $config->database->slave;
37
+	return new Aura\Sql\ExtendedPdo(
38
+		"mysql:host={$connection->host}",
39
+		$connection->user,
40
+		$connection->password
41
+	);
42 42
 });
43 43
 $db_connections->setWrite('master', function () use ($config) {
44
-    $connection = $config->database->master;
45
-    return new Aura\Sql\ExtendedPdo(
46
-        "mysql:host={$connection->host}",
47
-        $connection->user,
48
-        $connection->password
49
-    );
44
+	$connection = $config->database->master;
45
+	return new Aura\Sql\ExtendedPdo(
46
+		"mysql:host={$connection->host}",
47
+		$connection->user,
48
+		$connection->password
49
+	);
50 50
 });
51 51
 $db_connections->setRead('slave', function () use ($config) {
52
-    $connection = $config->database->slave;
53
-    $pdo = new Aura\Sql\ExtendedPdo(
54
-        "mysql:host={$connection->host}",
55
-        $connection->user,
56
-        $connection->password
57
-    );
58
-
59
-    $profiler = new Aura\Sql\Profiler();
60
-    $profiler->setActive(true);
61
-    $pdo->setProfiler($profiler);
62
-
63
-    return $pdo;
52
+	$connection = $config->database->slave;
53
+	$pdo = new Aura\Sql\ExtendedPdo(
54
+		"mysql:host={$connection->host}",
55
+		$connection->user,
56
+		$connection->password
57
+	);
58
+
59
+	$profiler = new Aura\Sql\Profiler();
60
+	$profiler->setActive(true);
61
+	$pdo->setProfiler($profiler);
62
+
63
+	return $pdo;
64 64
 });
65 65
 $container['db_connection_locator'] = $db_connections;
66 66
 
67 67
 
68 68
 // setup mail handler
69 69
 $container['mail'] = $container->factory(function ($c) {
70
-    return new Jacobemerick\Archangel\Archangel();
70
+	return new Jacobemerick\Archangel\Archangel();
71 71
 });
72 72
 
73 73
 
74 74
 // setup the logger
75 75
 $container['setup_logger'] = $container->protect(function ($name) use ($container) {
76
-    $logger = new Monolog\Logger($name);
76
+	$logger = new Monolog\Logger($name);
77 77
 
78
-    $logPath = __DIR__ . "/../logs/{$name}.log";
79
-    $streamHandler = new Monolog\Handler\StreamHandler($logPath, Monolog\Logger::INFO);
80
-    $streamHandler->setFormatter(
81
-        new Monolog\Formatter\LineFormatter("[%datetime%] %channel%.%level_name%: %message%\n")
82
-    );
83
-    $logger->pushHandler($streamHandler);
78
+	$logPath = __DIR__ . "/../logs/{$name}.log";
79
+	$streamHandler = new Monolog\Handler\StreamHandler($logPath, Monolog\Logger::INFO);
80
+	$streamHandler->setFormatter(
81
+		new Monolog\Formatter\LineFormatter("[%datetime%] %channel%.%level_name%: %message%\n")
82
+	);
83
+	$logger->pushHandler($streamHandler);
84 84
 
85
-    Monolog\ErrorHandler::register($logger);
86
-    $container['logger'] = $logger;
85
+	Monolog\ErrorHandler::register($logger);
86
+	$container['logger'] = $logger;
87 87
 });
88 88
 
89 89
 
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -25,14 +25,14 @@  discard block
 block discarded – undo
25 25
 
26 26
 // timezones are fun
27 27
 date_default_timezone_set('America/Phoenix'); // todo - belongs in configuration
28
-$container['default_timezone'] = function ($c) {
28
+$container['default_timezone'] = function($c) {
29 29
     return new DateTimeZone('America/Phoenix');
30 30
 };
31 31
 
32 32
 
33 33
 // configure the db connections holder
34 34
 $db_connections = new Aura\Sql\ConnectionLocator();
35
-$db_connections->setDefault(function () use ($config) {
35
+$db_connections->setDefault(function() use ($config) {
36 36
     $connection = $config->database->slave;
37 37
     return new Aura\Sql\ExtendedPdo(
38 38
         "mysql:host={$connection->host}",
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
         $connection->password
41 41
     );
42 42
 });
43
-$db_connections->setWrite('master', function () use ($config) {
43
+$db_connections->setWrite('master', function() use ($config) {
44 44
     $connection = $config->database->master;
45 45
     return new Aura\Sql\ExtendedPdo(
46 46
         "mysql:host={$connection->host}",
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
         $connection->password
49 49
     );
50 50
 });
51
-$db_connections->setRead('slave', function () use ($config) {
51
+$db_connections->setRead('slave', function() use ($config) {
52 52
     $connection = $config->database->slave;
53 53
     $pdo = new Aura\Sql\ExtendedPdo(
54 54
         "mysql:host={$connection->host}",
@@ -66,13 +66,13 @@  discard block
 block discarded – undo
66 66
 
67 67
 
68 68
 // setup mail handler
69
-$container['mail'] = $container->factory(function ($c) {
69
+$container['mail'] = $container->factory(function($c) {
70 70
     return new Jacobemerick\Archangel\Archangel();
71 71
 });
72 72
 
73 73
 
74 74
 // setup the logger
75
-$container['setup_logger'] = $container->protect(function ($name) use ($container) {
75
+$container['setup_logger'] = $container->protect(function($name) use ($container) {
76 76
     $logger = new Monolog\Logger($name);
77 77
 
78 78
     $logPath = __DIR__ . "/../logs/{$name}.log";
Please login to merge, or discard this patch.
script/cron/fetch-twitter-activity.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -6,40 +6,40 @@
 block discarded – undo
6 6
 use Jacobemerick\Web\Domain\Stream\Twitter\MysqlTwitterRepository as TwitterRepository;
7 7
 
8 8
 $client = new TwitterOAuth(
9
-    $config->twitter->consumer_key,
10
-    $config->twitter->consumer_secret,
11
-    $config->twitter->access_token,
12
-    $config->twitter->access_token_secret
9
+	$config->twitter->consumer_key,
10
+	$config->twitter->consumer_secret,
11
+	$config->twitter->access_token,
12
+	$config->twitter->access_token_secret
13 13
 );
14 14
 $client->setDecodeJsonAsArray(true);
15 15
 
16 16
 $twitterRepository = new TwitterRepository($container['db_connection_locator']);
17 17
 
18 18
 $recentTweets = $client->get('statuses/user_timeline', [
19
-    'screen_name' => 'jpemeric',
20
-    'count' => 50,
21
-    'trim_user' => true,
19
+	'screen_name' => 'jpemeric',
20
+	'count' => 50,
21
+	'trim_user' => true,
22 22
 ]);
23 23
 
24 24
 if (isset($recentTweets['errors'])) {
25
-    throw new Exception("Error encountered with twitter api {$recentTweets['errors'][0]['message']}");
25
+	throw new Exception("Error encountered with twitter api {$recentTweets['errors'][0]['message']}");
26 26
 }
27 27
 
28 28
 foreach ($recentTweets as $tweet) {
29
-    $uniqueTweetCheck = $twitterRepository->getTwitterByTweetId($tweet['id_str']);
30
-    if ($uniqueTweetCheck !== false) {
31
-        $currentTweetHash = md5($uniqueTweetCheck['metadata']);
32
-        $newTweetHash = md5(json_encode($tweet));
33
-        if ($uniqueTweetCheck['metadata'] != json_encode($tweet)) {
34
-            $twitterRepository->updateTweetMetadata($tweet['id_str'], $tweet);
35
-        }
36
-        continue;
37
-    }
38
-
39
-    $twitterRepository->insertTweet(
40
-        $tweet['id_str'],
41
-        (new DateTime($tweet['created_at']))->setTimezone($container['default_timezone']),
42
-        $tweet
43
-    );
29
+	$uniqueTweetCheck = $twitterRepository->getTwitterByTweetId($tweet['id_str']);
30
+	if ($uniqueTweetCheck !== false) {
31
+		$currentTweetHash = md5($uniqueTweetCheck['metadata']);
32
+		$newTweetHash = md5(json_encode($tweet));
33
+		if ($uniqueTweetCheck['metadata'] != json_encode($tweet)) {
34
+			$twitterRepository->updateTweetMetadata($tweet['id_str'], $tweet);
35
+		}
36
+		continue;
37
+	}
38
+
39
+	$twitterRepository->insertTweet(
40
+		$tweet['id_str'],
41
+		(new DateTime($tweet['created_at']))->setTimezone($container['default_timezone']),
42
+		$tweet
43
+	);
44 44
 }
45 45
 
Please login to merge, or discard this patch.