Completed
Push — master ( 5c8fbd...2c9aff )
by Jacob
03:19
created
src/Domain/Stream/Activity/MysqlActivityRepository.php 1 patch
Indentation   +146 added lines, -146 removed lines patch added patch discarded remove patch
@@ -8,192 +8,192 @@
 block discarded – undo
8 8
 class MysqlActivityRepository implements ActivityRepositoryInterface
9 9
 {
10 10
 
11
-    /** @var  ConnectionLocator */
12
-    protected $connections;
13
-
14
-    /**
15
-     * @param ConnectonLocator $connections
16
-     */
17
-    public function __construct(ConnectionLocator $connections)
18
-    {
19
-        $this->connections = $connections;
20
-    }
21
-
22
-    /**
23
-     * @param integer $id
24
-     *
25
-     * @return array|false
26
-     */
27
-    public function getActivityById($id)
28
-    {
29
-        $query = "
11
+	/** @var  ConnectionLocator */
12
+	protected $connections;
13
+
14
+	/**
15
+	 * @param ConnectonLocator $connections
16
+	 */
17
+	public function __construct(ConnectionLocator $connections)
18
+	{
19
+		$this->connections = $connections;
20
+	}
21
+
22
+	/**
23
+	 * @param integer $id
24
+	 *
25
+	 * @return array|false
26
+	 */
27
+	public function getActivityById($id)
28
+	{
29
+		$query = "
30 30
             SELECT *
31 31
             FROM `jpemeric_stream`.`activity`
32 32
             WHERE `id` = :id
33 33
             LIMIT 1";
34
-        $bindings = [
35
-            'id' => $id,
36
-        ];
37
-
38
-        return $this
39
-            ->connections
40
-            ->getRead()
41
-            ->fetchOne($query, $bindings);
42
-    }
43
-
44
-    public function getActivityByTypeId($type, $typeId)
45
-    {
46
-        $query = "
34
+		$bindings = [
35
+			'id' => $id,
36
+		];
37
+
38
+		return $this
39
+			->connections
40
+			->getRead()
41
+			->fetchOne($query, $bindings);
42
+	}
43
+
44
+	public function getActivityByTypeId($type, $typeId)
45
+	{
46
+		$query = "
47 47
             SELECT *
48 48
             FROM `jpemeric_stream`.`activity`
49 49
             WHERE `type` = :type && `type_id` = :type_id
50 50
             LIMIT 1";
51
-        $bindings = [
52
-            'type'    => $type,
53
-            'type_id' => $typeId,
54
-        ];
55
-
56
-        return $this
57
-            ->connections
58
-            ->getRead()
59
-            ->fetchOne($query, $bindings);
60
-    }
61
-
62
-    public function getActivityLastUpdateByType($type)
63
-    {
64
-        $query = "
51
+		$bindings = [
52
+			'type'    => $type,
53
+			'type_id' => $typeId,
54
+		];
55
+
56
+		return $this
57
+			->connections
58
+			->getRead()
59
+			->fetchOne($query, $bindings);
60
+	}
61
+
62
+	public function getActivityLastUpdateByType($type)
63
+	{
64
+		$query = "
65 65
             SELECT *
66 66
             FROM `jpemeric_stream`.`activity`
67 67
             WHERE `type` = :type
68 68
             ORDER BY `updated_at` DESC
69 69
             LIMIT 1";
70 70
 
71
-        $bindings = [
72
-            'type' => $type,
73
-        ];
74
-
75
-        return $this
76
-            ->connections
77
-            ->getRead()
78
-            ->fetchOne($query, $bindings);
79
-    }
80
-
81
-    /**
82
-     * @param integer $limit
83
-     * @param integer $offset
84
-     *
85
-     * @return array|false
86
-     */
87
-    public function getActivities($limit = null, $offset = 0)
88
-    {
89
-        $query = "
71
+		$bindings = [
72
+			'type' => $type,
73
+		];
74
+
75
+		return $this
76
+			->connections
77
+			->getRead()
78
+			->fetchOne($query, $bindings);
79
+	}
80
+
81
+	/**
82
+	 * @param integer $limit
83
+	 * @param integer $offset
84
+	 *
85
+	 * @return array|false
86
+	 */
87
+	public function getActivities($limit = null, $offset = 0)
88
+	{
89
+		$query = "
90 90
             SELECT *
91 91
             FROM `jpemeric_stream`.`activity`
92 92
             ORDER BY `datetime` DESC";
93
-        if (!is_null($limit)) {
94
-            $query .= "
93
+		if (!is_null($limit)) {
94
+			$query .= "
95 95
             LIMIT {$offset}, {$limit}";
96
-        }
96
+		}
97 97
 
98
-        return $this
99
-            ->connections
100
-            ->getRead()
101
-            ->fetchAll($query);
102
-    }
98
+		return $this
99
+			->connections
100
+			->getRead()
101
+			->fetchAll($query);
102
+	}
103 103
 
104
-    public function getActivitiesCount()
105
-    {
106
-        $query = "
104
+	public function getActivitiesCount()
105
+	{
106
+		$query = "
107 107
             SELECT COUNT(1) AS `count`
108 108
             FROM `jpemeric_stream`.`activity`";
109 109
 
110
-        return $this
111
-            ->connections
112
-            ->getRead()
113
-            ->fetchValue($query);
114
-    }
110
+		return $this
111
+			->connections
112
+			->getRead()
113
+			->fetchValue($query);
114
+	}
115 115
 
116
-    public function getActivitiesByType($type, $limit = null, $offset = 0)
117
-    {
118
-        $query = "
116
+	public function getActivitiesByType($type, $limit = null, $offset = 0)
117
+	{
118
+		$query = "
119 119
             SELECT *
120 120
             FROM `jpemeric_stream`.`activity`
121 121
             WHERE `type` = :type
122 122
             ORDER BY `datetime` DESC";
123
-        if (!is_null($limit)) {
124
-            $query .= "
123
+		if (!is_null($limit)) {
124
+			$query .= "
125 125
             LIMIT {$offset}, {$limit}";
126
-        }
127
-        $bindings = [
128
-            'type' => $type,
129
-        ];
130
-
131
-        return $this
132
-            ->connections
133
-            ->getRead()
134
-            ->fetchAll($query, $bindings);
135
-    }
136
-
137
-    public function getActivitiesByTypeCount($type)
138
-    {
139
-        $query = "
126
+		}
127
+		$bindings = [
128
+			'type' => $type,
129
+		];
130
+
131
+		return $this
132
+			->connections
133
+			->getRead()
134
+			->fetchAll($query, $bindings);
135
+	}
136
+
137
+	public function getActivitiesByTypeCount($type)
138
+	{
139
+		$query = "
140 140
             SELECT COUNT(1) AS `count`
141 141
             FROM `jpemeric_stream`.`activity`
142 142
             WHERE `type` = :type";
143
-        $bindings = [
144
-            'type' => $type,
145
-        ];
146
-
147
-        return $this
148
-            ->connections
149
-            ->getRead()
150
-            ->fetchValue($query, $bindings);
151
-    }
152
-
153
-    public function insertActivity(
154
-        $message,
155
-        $messageLong,
156
-        DateTime $datetime,
157
-        array $metadata,
158
-        $type,
159
-        $typeId
160
-    ) {
161
-        $query = "
143
+		$bindings = [
144
+			'type' => $type,
145
+		];
146
+
147
+		return $this
148
+			->connections
149
+			->getRead()
150
+			->fetchValue($query, $bindings);
151
+	}
152
+
153
+	public function insertActivity(
154
+		$message,
155
+		$messageLong,
156
+		DateTime $datetime,
157
+		array $metadata,
158
+		$type,
159
+		$typeId
160
+	) {
161
+		$query = "
162 162
             INSERT INTO `jpemeric_stream`.`activity`
163 163
                 (`message`, `message_long`, `datetime`, `metadata`, `type`, `type_id`)
164 164
             VALUES
165 165
                 (:message, :message_long, :datetime, :metadata, :type, :type_id)";
166 166
 
167
-        $bindings = [
168
-            'message' => $message,
169
-            'message_long' => $messageLong,
170
-            'datetime' => $datetime->format('Y-m-d H:i:s'),
171
-            'metadata' => json_encode($metadata),
172
-            'type' => $type,
173
-            'type_id' => $typeId,
174
-        ];
175
-
176
-        return $this
177
-            ->connections
178
-            ->getWrite()
179
-            ->perform($query, $bindings);
180
-    }
181
-
182
-    public function updateActivityMetadata($activityId, array $metadata)
183
-    {
184
-        $query = "
167
+		$bindings = [
168
+			'message' => $message,
169
+			'message_long' => $messageLong,
170
+			'datetime' => $datetime->format('Y-m-d H:i:s'),
171
+			'metadata' => json_encode($metadata),
172
+			'type' => $type,
173
+			'type_id' => $typeId,
174
+		];
175
+
176
+		return $this
177
+			->connections
178
+			->getWrite()
179
+			->perform($query, $bindings);
180
+	}
181
+
182
+	public function updateActivityMetadata($activityId, array $metadata)
183
+	{
184
+		$query = "
185 185
             UPDATE `jpemeric_stream`.`activity`
186 186
             SET `metadata` = :metadata
187 187
             WHERE `id` = :id";
188 188
 
189
-        $bindings = [
190
-            'metadata' => json_encode($metadata),
191
-            'id' => $activityId,
192
-        ];
189
+		$bindings = [
190
+			'metadata' => json_encode($metadata),
191
+			'id' => $activityId,
192
+		];
193 193
 
194
-        return $this
195
-            ->connections
196
-            ->getWrite()
197
-            ->perform($query, $bindings);
198
-    }
194
+		return $this
195
+			->connections
196
+			->getWrite()
197
+			->perform($query, $bindings);
198
+	}
199 199
 }
Please login to merge, or discard this patch.
src/Domain/Stream/DailyMile/MysqlDailyMileRepository.php 1 patch
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -8,106 +8,106 @@
 block discarded – undo
8 8
 class MysqlDailyMileRepository implements DailyMileRepositoryInterface
9 9
 {
10 10
 
11
-    /** @var  ConnectionLocator */
12
-    protected $connections;
13
-
14
-    /**
15
-     * @param ConnectonLocator $connections
16
-     */
17
-    public function __construct(ConnectionLocator $connections)
18
-    {
19
-        $this->connections = $connections;
20
-    }
21
-
22
-    /**
23
-     * @param integer $limit
24
-     * @param integer $offset
25
-     *
26
-     * @return array|false
27
-     */
28
-    public function getEntries($limit = null, $offset = 0)
29
-    {
30
-        $query = "
11
+	/** @var  ConnectionLocator */
12
+	protected $connections;
13
+
14
+	/**
15
+	 * @param ConnectonLocator $connections
16
+	 */
17
+	public function __construct(ConnectionLocator $connections)
18
+	{
19
+		$this->connections = $connections;
20
+	}
21
+
22
+	/**
23
+	 * @param integer $limit
24
+	 * @param integer $offset
25
+	 *
26
+	 * @return array|false
27
+	 */
28
+	public function getEntries($limit = null, $offset = 0)
29
+	{
30
+		$query = "
31 31
             SELECT `id`, `entry_id`, `datetime`
32 32
             FROM `jpemeric_stream`.`dailymile`
33 33
             ORDER BY `datetime` DESC";
34
-        if (!is_null($limit)) {
35
-          $query .= "
34
+		if (!is_null($limit)) {
35
+		  $query .= "
36 36
           LIMIT {$offset}, {$limit}";
37
-        }
38
-
39
-        return $this
40
-            ->connections
41
-            ->getRead()
42
-            ->fetchAll($query);
43
-    }
44
-
45
-    /**
46
-     * @param integer $entryId
47
-     *
48
-     * @return array|false
49
-     */
50
-    public function getEntryByEntryId($entryId)
51
-    {
52
-        $query = "
37
+		}
38
+
39
+		return $this
40
+			->connections
41
+			->getRead()
42
+			->fetchAll($query);
43
+	}
44
+
45
+	/**
46
+	 * @param integer $entryId
47
+	 *
48
+	 * @return array|false
49
+	 */
50
+	public function getEntryByEntryId($entryId)
51
+	{
52
+		$query = "
53 53
             SELECT *
54 54
             FROM `jpemeric_stream`.`dailymile`
55 55
             WHERE `entry_id` = :entry_id
56 56
             LIMIT 1";
57 57
 
58
-        $bindings = [
59
-            'entry_id' => $entryId,
60
-        ];
58
+		$bindings = [
59
+			'entry_id' => $entryId,
60
+		];
61 61
 
62
-        return $this
63
-            ->connections
64
-            ->getRead()
65
-            ->fetchOne($query, $bindings);
66
-    }
62
+		return $this
63
+			->connections
64
+			->getRead()
65
+			->fetchOne($query, $bindings);
66
+	}
67 67
 
68
-    public function getDailyMilesUpdatedSince(DateTime $datetime)
69
-    {
70
-        $query = "
68
+	public function getDailyMilesUpdatedSince(DateTime $datetime)
69
+	{
70
+		$query = "
71 71
             SELECT *
72 72
             FROM `jpemeric_stream`.`dailymile`
73 73
             WHERE `updated_at` >= :last_update";
74 74
 
75
-        $bindings = [
76
-            'last_update' => $datetime->format('Y-m-d H:i:s'),
77
-        ];
78
-
79
-        return $this
80
-            ->connections
81
-            ->getRead()
82
-            ->fetchAll($query, $bindings);
83
-    }
84
-
85
-    /**
86
-     * @param integer  $entryId
87
-     * @param string   $entryType
88
-     * @param DateTime $datetime
89
-     * @param array    $metadata
90
-     *
91
-     * @return
92
-     */
93
-    public function insertEntry($entryId, $entryType, DateTime $datetime, array $metadata)
94
-    {
95
-        $query = "
75
+		$bindings = [
76
+			'last_update' => $datetime->format('Y-m-d H:i:s'),
77
+		];
78
+
79
+		return $this
80
+			->connections
81
+			->getRead()
82
+			->fetchAll($query, $bindings);
83
+	}
84
+
85
+	/**
86
+	 * @param integer  $entryId
87
+	 * @param string   $entryType
88
+	 * @param DateTime $datetime
89
+	 * @param array    $metadata
90
+	 *
91
+	 * @return
92
+	 */
93
+	public function insertEntry($entryId, $entryType, DateTime $datetime, array $metadata)
94
+	{
95
+		$query = "
96 96
             INSERT INTO `jpemeric_stream`.`dailymile`
97 97
                 (`entry_id`, `type`, `datetime`, `metadata`)
98 98
             VALUES
99 99
                 (:entry_id, :entry_type, :datetime, :metadata)";
100 100
 
101
-        $bindings = [
102
-            'entry_id' => $entryId,
103
-            'entry_type' => $entryType,
104
-            'datetime' => $datetime->format('Y-m-d H:i:s'),
105
-            'metadata' => json_encode($metadata),
106
-        ];
107
-
108
-        return $this
109
-            ->connections
110
-            ->getWrite()
111
-            ->perform($query, $bindings);
112
-    }
101
+		$bindings = [
102
+			'entry_id' => $entryId,
103
+			'entry_type' => $entryType,
104
+			'datetime' => $datetime->format('Y-m-d H:i:s'),
105
+			'metadata' => json_encode($metadata),
106
+		];
107
+
108
+		return $this
109
+			->connections
110
+			->getWrite()
111
+			->perform($query, $bindings);
112
+	}
113 113
 }
Please login to merge, or discard this patch.
src/Domain/Stream/Goodread/MysqlGoodreadRepository.php 1 patch
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -8,93 +8,93 @@
 block discarded – undo
8 8
 class MysqlGoodreadRepository implements GoodreadRepositoryInterface
9 9
 {
10 10
 
11
-    /** @var  ConnectionLocator */
12
-    protected $connections;
13
-
14
-    /**
15
-     * @param ConnectonLocator $connections
16
-     */
17
-    public function __construct(ConnectionLocator $connections)
18
-    {
19
-        $this->connections = $connections;
20
-    }
21
-
22
-    /**
23
-     * @param integer $limit
24
-     * @param integer $offset
25
-     *
26
-     * @return array|false
27
-     */
28
-    public function getReviews($limit = null, $offset = 0)
29
-    {
30
-        $query = "
11
+	/** @var  ConnectionLocator */
12
+	protected $connections;
13
+
14
+	/**
15
+	 * @param ConnectonLocator $connections
16
+	 */
17
+	public function __construct(ConnectionLocator $connections)
18
+	{
19
+		$this->connections = $connections;
20
+	}
21
+
22
+	/**
23
+	 * @param integer $limit
24
+	 * @param integer $offset
25
+	 *
26
+	 * @return array|false
27
+	 */
28
+	public function getReviews($limit = null, $offset = 0)
29
+	{
30
+		$query = "
31 31
             SELECT `id`, `permalink`, `datetime`
32 32
             FROM `jpemeric_stream`.`goodread`
33 33
             ORDER BY `datetime` DESC";
34
-        if (!is_null($limit)) {
35
-          $query .= "
34
+		if (!is_null($limit)) {
35
+		  $query .= "
36 36
           LIMIT {$offset}, {$limit}";
37
-        }
37
+		}
38 38
 
39
-        return $this
40
-            ->connections
41
-            ->getRead()
42
-            ->fetchAll($query);
43
-    }
39
+		return $this
40
+			->connections
41
+			->getRead()
42
+			->fetchAll($query);
43
+	}
44 44
 
45
-    public function getReviewByPermalink($permalink)
46
-    {
47
-        $query = "
45
+	public function getReviewByPermalink($permalink)
46
+	{
47
+		$query = "
48 48
             SELECT *
49 49
             FROM `jpemeric_stream`.`goodread`
50 50
             WHERE `permalink` = :permalink
51 51
             LIMIT 1";
52 52
 
53
-        $bindings = [
54
-            'permalink' => $permalink,
55
-        ];
53
+		$bindings = [
54
+			'permalink' => $permalink,
55
+		];
56 56
 
57
-        return $this
58
-            ->connections
59
-            ->getRead()
60
-            ->fetchOne($query, $bindings);
61
-    }
57
+		return $this
58
+			->connections
59
+			->getRead()
60
+			->fetchOne($query, $bindings);
61
+	}
62 62
 
63
-    public function getGoodreadsUpdatedSince(DateTime $datetime)
64
-    {
65
-        $query = "
63
+	public function getGoodreadsUpdatedSince(DateTime $datetime)
64
+	{
65
+		$query = "
66 66
             SELECT *
67 67
             FROM `jpemeric_stream`.`goodread`
68 68
             WHERE `updated_at` >= :last_update";
69 69
 
70
-        $bindings = [
71
-            'last_update' => $datetime->format('Y-m-d H:i:s'),
72
-        ];
70
+		$bindings = [
71
+			'last_update' => $datetime->format('Y-m-d H:i:s'),
72
+		];
73 73
 
74
-        return $this
75
-            ->connections
76
-            ->getRead()
77
-            ->fetchAll($query, $bindings);
78
-    }
74
+		return $this
75
+			->connections
76
+			->getRead()
77
+			->fetchAll($query, $bindings);
78
+	}
79 79
 
80
-    public function insertReview($permalink, $bookId, DateTime $datetime, array $metadata)
81
-    {
82
-        $query = "
80
+	public function insertReview($permalink, $bookId, DateTime $datetime, array $metadata)
81
+	{
82
+		$query = "
83 83
             INSERT INTO `jpemeric_stream`.`goodread`
84 84
                 (`permalink`, `book_id`, `datetime`, `metadata`)
85 85
             VALUES
86 86
                 (:permalink, :book_id, :datetime, :metadata)";
87 87
 
88
-        $bindings = [
89
-            'permalink' => $permalink,
90
-            'book_id' => $bookId,
91
-            'datetime' => $datetime->format('Y-m-d H:i:s'),
92
-            'metadata' => json_encode($metadata),
93
-        ];
94
-
95
-        return $this
96
-            ->connections
97
-            ->getWrite()
98
-            ->perform($query, $bindings);
99
-    }
88
+		$bindings = [
89
+			'permalink' => $permalink,
90
+			'book_id' => $bookId,
91
+			'datetime' => $datetime->format('Y-m-d H:i:s'),
92
+			'metadata' => json_encode($metadata),
93
+		];
94
+
95
+		return $this
96
+			->connections
97
+			->getWrite()
98
+			->perform($query, $bindings);
99
+	}
100 100
 }
Please login to merge, or discard this patch.
src/Domain/Stream/Github/MysqlGithubRepository.php 1 patch
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -8,104 +8,104 @@
 block discarded – undo
8 8
 class MysqlGithubRepository implements GithubRepositoryInterface
9 9
 {
10 10
 
11
-    /** @var  ConnectionLocator */
12
-    protected $connections;
11
+	/** @var  ConnectionLocator */
12
+	protected $connections;
13 13
 
14
-    /**
15
-     * @param ConnectonLocator $connections
16
-     */
17
-    public function __construct(ConnectionLocator $connections)
18
-    {
19
-        $this->connections = $connections;
20
-    }
14
+	/**
15
+	 * @param ConnectonLocator $connections
16
+	 */
17
+	public function __construct(ConnectionLocator $connections)
18
+	{
19
+		$this->connections = $connections;
20
+	}
21 21
 
22
-    /**
23
-     * @param integer $limit
24
-     * @param integer $offset
25
-     *
26
-     * @return array|false
27
-     */
28
-    public function getEvents($limit = null, $offset = 0)
29
-    {
30
-        $query = "
22
+	/**
23
+	 * @param integer $limit
24
+	 * @param integer $offset
25
+	 *
26
+	 * @return array|false
27
+	 */
28
+	public function getEvents($limit = null, $offset = 0)
29
+	{
30
+		$query = "
31 31
             SELECT `id`, `event_id`, `datetime`
32 32
             FROM `jpemeric_stream`.`github`
33 33
             ORDER BY `datetime` DESC";
34
-        if (!is_null($limit)) {
35
-            $query .= "
34
+		if (!is_null($limit)) {
35
+			$query .= "
36 36
             LIMIT {$offset}, {$limit}";
37
-        }
37
+		}
38 38
 
39
-        return $this
40
-            ->connections
41
-            ->getRead()
42
-            ->fetchAll($query);
43
-    }
39
+		return $this
40
+			->connections
41
+			->getRead()
42
+			->fetchAll($query);
43
+	}
44 44
 
45
-    /**
46
-     * @param integer $eventId
47
-     *
48
-     * @return array|false
49
-     */
50
-    public function getEventByEventId($eventId)
51
-    {
52
-        $query = "
45
+	/**
46
+	 * @param integer $eventId
47
+	 *
48
+	 * @return array|false
49
+	 */
50
+	public function getEventByEventId($eventId)
51
+	{
52
+		$query = "
53 53
             SELECT *
54 54
             FROM `jpemeric_stream`.`github`
55 55
             WHERE `event_id` = :event_id
56 56
             LIMIT 1";
57 57
 
58
-        $bindings = [
59
-            'event_id' => $eventId,
60
-        ];
58
+		$bindings = [
59
+			'event_id' => $eventId,
60
+		];
61 61
 
62
-        return $this
63
-            ->connections
64
-            ->getRead()
65
-            ->fetchOne($query, $bindings);
66
-    }
62
+		return $this
63
+			->connections
64
+			->getRead()
65
+			->fetchOne($query, $bindings);
66
+	}
67 67
 
68
-    public function getGithubsUpdatedSince(DateTime $datetime)
69
-    {
70
-        $query = "
68
+	public function getGithubsUpdatedSince(DateTime $datetime)
69
+	{
70
+		$query = "
71 71
             SELECT *
72 72
             FROM `jpemeric_stream`.`github`
73 73
             WHERE `updated_at` >= :last_update";
74
-        $bindings = [
75
-            'last_update' => $datetime->format('Y-m-d H:i:s'),
76
-        ];
77
-        return $this
78
-            ->connections
79
-            ->getRead()
80
-            ->fetchAll($query, $bindings);
81
-    }
74
+		$bindings = [
75
+			'last_update' => $datetime->format('Y-m-d H:i:s'),
76
+		];
77
+		return $this
78
+			->connections
79
+			->getRead()
80
+			->fetchAll($query, $bindings);
81
+	}
82 82
 
83
-    /**
84
-     * @param integer  $eventId
85
-     * @param string   $eventType
86
-     * @param DateTime $datetime
87
-     * @param array    $metadata
88
-     *
89
-     * @return
90
-     */
91
-    public function insertEvent($eventId, $eventType, DateTime $datetime, array $metadata)
92
-    {
93
-        $query = "
83
+	/**
84
+	 * @param integer  $eventId
85
+	 * @param string   $eventType
86
+	 * @param DateTime $datetime
87
+	 * @param array    $metadata
88
+	 *
89
+	 * @return
90
+	 */
91
+	public function insertEvent($eventId, $eventType, DateTime $datetime, array $metadata)
92
+	{
93
+		$query = "
94 94
             INSERT INTO `jpemeric_stream`.`github`
95 95
                 (`event_id`, `type`, `datetime`, `metadata`)
96 96
             VALUES
97 97
                 (:event_id, :event_type, :datetime, :metadata)";
98 98
 
99
-        $bindings = [
100
-            'event_id' => $eventId,
101
-            'event_type' => $eventType,
102
-            'datetime' => $datetime->format('Y-m-d H:i:s'),
103
-            'metadata' => json_encode($metadata),
104
-        ];
99
+		$bindings = [
100
+			'event_id' => $eventId,
101
+			'event_type' => $eventType,
102
+			'datetime' => $datetime->format('Y-m-d H:i:s'),
103
+			'metadata' => json_encode($metadata),
104
+		];
105 105
 
106
-        return $this
107
-            ->connections
108
-            ->getWrite()
109
-            ->perform($query, $bindings);
110
-    }
106
+		return $this
107
+			->connections
108
+			->getWrite()
109
+			->perform($query, $bindings);
110
+	}
111 111
 }
Please login to merge, or discard this patch.
controller/lifestream/DefaultPageController.class.inc.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,10 +10,10 @@
 block discarded – undo
10 10
 
11 11
   public function __construct()
12 12
   {
13
-    parent::__construct();
13
+	parent::__construct();
14 14
 
15
-    global $container;
16
-    $this->activityRepository = new Jacobemerick\Web\Domain\Stream\Activity\MysqlActivityRepository($container['db_connection_locator']);
15
+	global $container;
16
+	$this->activityRepository = new Jacobemerick\Web\Domain\Stream\Activity\MysqlActivityRepository($container['db_connection_locator']);
17 17
   }
18 18
 
19 19
 	protected function set_head_data()
Please login to merge, or discard this patch.
script/cron/generate-sitemaps.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  * @param string $domain
27 27
  * @return boolean
28 28
  */
29
-$buildSitemap = function (array $entries, $domain, $folder) {
29
+$buildSitemap = function(array $entries, $domain, $folder) {
30 30
     $urlSet = new Urlset();
31 31
     foreach ($entries as $path => $entry) {
32 32
         $url = new Url("{$domain}{$path}"); // todo better detection of domain by env
@@ -53,13 +53,13 @@  discard block
 block discarded – undo
53 53
 /*********************************************
54 54
  * blog.jacobemerick.com
55 55
  *********************************************/
56
-$reduceToMostRecentBlogPost = function ($recentPost, $post) {
56
+$reduceToMostRecentBlogPost = function($recentPost, $post) {
57 57
     if (is_null($recentPost)) {
58 58
         return $post;
59 59
     }
60 60
     $postDate = new DateTime($post['date']);
61 61
     $recentPostDate = new DateTime($recentPost['date']);
62
-    return ($postDate > $recentPostDate) ? $post: $recentPost;
62
+    return ($postDate > $recentPostDate) ? $post : $recentPost;
63 63
 };
64 64
 
65 65
 $blogPostsPerPage = 10;
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 ];
95 95
 
96 96
 foreach ($blogCategoryArray as $blogCategory) {
97
-    $blogCategoryPosts = array_filter($activeBlogPosts, function ($post) use ($blogCategory) {
97
+    $blogCategoryPosts = array_filter($activeBlogPosts, function($post) use ($blogCategory) {
98 98
         return $post['category'] == $blogCategory;
99 99
     });
100 100
     $mostRecentBlogCategoryPost = array_reduce($blogCategoryPosts, $reduceToMostRecentBlogPost);
@@ -207,13 +207,13 @@  discard block
 block discarded – undo
207 207
 /*********************************************
208 208
  * lifestream.jacobemerick.com
209 209
  *********************************************/
210
-$reduceToMostRecentStreamActivity = function ($recentActivity, $activity) {
210
+$reduceToMostRecentStreamActivity = function($recentActivity, $activity) {
211 211
     if (is_null($recentActivity)) {
212 212
         return $activity;
213 213
     }
214 214
     $activityDate = new DateTime($activity['datetime']);
215 215
     $recentActivityDate = new DateTime($recentActivity['datetime']);
216
-    return ($activityDate > $recentActivityDate) ? $activity: $recentActivity;
216
+    return ($activityDate > $recentActivityDate) ? $activity : $recentActivity;
217 217
 };
218 218
 
219 219
 $streamActivitiesPerPage = 15;
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 ];
252 252
 
253 253
 foreach ($streamTypeArray as $streamType) {
254
-    $streamTypeActivities = array_filter($streamActivities, function ($post) use ($streamType) {
254
+    $streamTypeActivities = array_filter($streamActivities, function($post) use ($streamType) {
255 255
         return $post['type'] == $streamType;
256 256
     });
257 257
     $mostRecentStreamTypeActivity = array_reduce($streamTypeActivities, $reduceToMostRecentStreamActivity);
@@ -385,13 +385,13 @@  discard block
 block discarded – undo
385 385
 /*********************************************
386 386
  * www.waterfallofthekeweenaw.com
387 387
  *********************************************/
388
-$reduceToMostRecentJournalLog = function ($recentLog, $log) {
388
+$reduceToMostRecentJournalLog = function($recentLog, $log) {
389 389
     if (is_null($recentLog)) {
390 390
         return $log;
391 391
     }
392 392
     $logDate = new DateTime($log['publish_date']);
393 393
     $recentLogDate = new DateTime($recentLog['publish_date']);
394
-    return ($logDate > $recentLogDate) ? log: $recentLog;
394
+    return ($logDate > $recentLogDate) ? log : $recentLog;
395 395
 };
396 396
 
397 397
 $waterfallRepository = new WaterfallRepository($container['db_connection_locator']);
Please login to merge, or discard this patch.
Indentation   +378 added lines, -378 removed lines patch added patch discarded remove patch
@@ -27,26 +27,26 @@  discard block
 block discarded – undo
27 27
  * @return boolean
28 28
  */
29 29
 $buildSitemap = function (array $entries, $domain, $folder) {
30
-    $urlSet = new Urlset();
31
-    foreach ($entries as $path => $entry) {
32
-        $url = new Url("{$domain}{$path}"); // todo better detection of domain by env
33
-        $url->setLastMod($entry['lastmod']); // todo check if exists
34
-        $url->setChangeFreq($entry['changefreq']); // todo check if exists
35
-        $url->setPriority($entry['priority']); // todo check if exists
36
-        $urlSet->addUrl($url);
37
-    }
38
-
39
-    $output = new Output();
40
-    $output->setIndentString('  '); // change indentation from 4 to 2 spaces
41
-
42
-    $tempSitemap = __DIR__ . "/../../public/{$folder}/sitemap-new.xml";
43
-    $finalSitemap = __DIR__ . "/../../public/{$folder}/sitemap.xml";
44
-
45
-    $sitemapHandle = fopen($tempSitemap, 'w');
46
-    fwrite($sitemapHandle, $output->getOutput($urlSet));
47
-    fclose($sitemapHandle);
48
-
49
-    rename($tempSitemap, $finalSitemap);
30
+	$urlSet = new Urlset();
31
+	foreach ($entries as $path => $entry) {
32
+		$url = new Url("{$domain}{$path}"); // todo better detection of domain by env
33
+		$url->setLastMod($entry['lastmod']); // todo check if exists
34
+		$url->setChangeFreq($entry['changefreq']); // todo check if exists
35
+		$url->setPriority($entry['priority']); // todo check if exists
36
+		$urlSet->addUrl($url);
37
+	}
38
+
39
+	$output = new Output();
40
+	$output->setIndentString('  '); // change indentation from 4 to 2 spaces
41
+
42
+	$tempSitemap = __DIR__ . "/../../public/{$folder}/sitemap-new.xml";
43
+	$finalSitemap = __DIR__ . "/../../public/{$folder}/sitemap.xml";
44
+
45
+	$sitemapHandle = fopen($tempSitemap, 'w');
46
+	fwrite($sitemapHandle, $output->getOutput($urlSet));
47
+	fclose($sitemapHandle);
48
+
49
+	rename($tempSitemap, $finalSitemap);
50 50
 };
51 51
 
52 52
 
@@ -54,12 +54,12 @@  discard block
 block discarded – undo
54 54
  * blog.jacobemerick.com
55 55
  *********************************************/
56 56
 $reduceToMostRecentBlogPost = function ($recentPost, $post) {
57
-    if (is_null($recentPost)) {
58
-        return $post;
59
-    }
60
-    $postDate = new DateTime($post['date']);
61
-    $recentPostDate = new DateTime($recentPost['date']);
62
-    return ($postDate > $recentPostDate) ? $post: $recentPost;
57
+	if (is_null($recentPost)) {
58
+		return $post;
59
+	}
60
+	$postDate = new DateTime($post['date']);
61
+	$recentPostDate = new DateTime($recentPost['date']);
62
+	return ($postDate > $recentPostDate) ? $post: $recentPost;
63 63
 };
64 64
 
65 65
 $blogPostsPerPage = 10;
@@ -70,107 +70,107 @@  discard block
 block discarded – undo
70 70
 
71 71
 // todo these post-level dates should be accurate to H:i:s
72 72
 $entryArray = [
73
-    '/' => [
74
-        'lastmod' => (new DateTime($mostRecentBlogPost['date']))->format('Y-m-d'),
75
-        'changefreq' => 'daily',
76
-        'priority' => .9,
77
-    ]
73
+	'/' => [
74
+		'lastmod' => (new DateTime($mostRecentBlogPost['date']))->format('Y-m-d'),
75
+		'changefreq' => 'daily',
76
+		'priority' => .9,
77
+	]
78 78
 ];
79 79
 for ($i = 2; (($i - 1) * $blogPostsPerPage) < count($activeBlogPosts); $i++) {
80
-    $entryKey = "/{$i}/";
81
-    $entryArray += [
82
-        $entryKey => [
83
-            'lastmod' => (new DateTime($mostRecentBlogPost['date']))->format('Y-m-d'),
84
-            'changefreq' => 'daily',
85
-            'priority' => .1,
86
-        ]
87
-    ];
80
+	$entryKey = "/{$i}/";
81
+	$entryArray += [
82
+		$entryKey => [
83
+			'lastmod' => (new DateTime($mostRecentBlogPost['date']))->format('Y-m-d'),
84
+			'changefreq' => 'daily',
85
+			'priority' => .1,
86
+		]
87
+	];
88 88
 }
89 89
 
90 90
 $blogCategoryArray = [
91
-    'hiking',
92
-    'personal',
93
-    'web-development',
91
+	'hiking',
92
+	'personal',
93
+	'web-development',
94 94
 ];
95 95
 
96 96
 foreach ($blogCategoryArray as $blogCategory) {
97
-    $blogCategoryPosts = array_filter($activeBlogPosts, function ($post) use ($blogCategory) {
98
-        return $post['category'] == $blogCategory;
99
-    });
100
-    $mostRecentBlogCategoryPost = array_reduce($blogCategoryPosts, $reduceToMostRecentBlogPost);
101
-
102
-    $entryKey = "/{$blogCategory}/";
103
-    $entryArray += [
104
-        $entryKey => [
105
-            'lastmod' => (new DateTime($mostRecentBlogCategoryPost['date']))->format('Y-m-d'),
106
-            'changefreq' => 'daily',
107
-            'priority' => .3,
108
-        ]
109
-    ];
110
-
111
-    for ($i = 2; (($i - 1) * $blogPostsPerPage) < count($blogCategoryPosts); $i++) {
112
-        $entryKey = "/{$blogCategory}/{$i}/";
113
-        $entryArray += [
114
-            $entryKey => [
115
-                'lastmod' => (new DateTime($mostRecentBlogCategoryPost['date']))->format('Y-m-d'),
116
-                'changefreq' => 'daily',
117
-                'priority' => .1,
118
-            ]
119
-        ];
120
-    }
97
+	$blogCategoryPosts = array_filter($activeBlogPosts, function ($post) use ($blogCategory) {
98
+		return $post['category'] == $blogCategory;
99
+	});
100
+	$mostRecentBlogCategoryPost = array_reduce($blogCategoryPosts, $reduceToMostRecentBlogPost);
101
+
102
+	$entryKey = "/{$blogCategory}/";
103
+	$entryArray += [
104
+		$entryKey => [
105
+			'lastmod' => (new DateTime($mostRecentBlogCategoryPost['date']))->format('Y-m-d'),
106
+			'changefreq' => 'daily',
107
+			'priority' => .3,
108
+		]
109
+	];
110
+
111
+	for ($i = 2; (($i - 1) * $blogPostsPerPage) < count($blogCategoryPosts); $i++) {
112
+		$entryKey = "/{$blogCategory}/{$i}/";
113
+		$entryArray += [
114
+			$entryKey => [
115
+				'lastmod' => (new DateTime($mostRecentBlogCategoryPost['date']))->format('Y-m-d'),
116
+				'changefreq' => 'daily',
117
+				'priority' => .1,
118
+			]
119
+		];
120
+	}
121 121
 }
122 122
 
123 123
 $blogTagRepository = new BlogTagRepository($container['db_connection_locator']);
124 124
 $blogTags = $blogTagRepository->getAllTags();
125 125
 foreach ($blogTags as $blogTag) {
126
-    $blogPostsWithTag = $blogPostRepository->getActivePostsByTag($blogTag['id']);
127
-    if (count($blogPostsWithTag) < 1) {
128
-        continue;
129
-    }
130
-
131
-    $mostRecentBlogTagPost = array_reduce($blogPostsWithTag, $reduceToMostRecentBlogPost);
132
-
133
-    $blogTagPath = str_replace(' ', '-', $blogTag['tag']);
134
-    $entryKey = "/tag/{$blogTagPath}/";
135
-    $entryArray += [
136
-        $entryKey => [
137
-            'lastmod' => (new DateTime($mostRecentBlogTagPost['date']))->format('Y-m-d'),
138
-            'changefreq' => 'daily',
139
-            'priority' => .1,
140
-        ]
141
-    ];
142
-
143
-    for ($i = 2; (($i - 1) * $blogPostsPerPage) < count($blogPostsWithTag); $i++) {
144
-        $blogTagPath = str_replace(' ', '-', $blogTag['tag']);
145
-        $entryKey = "/tag/{$blogTagPath}/{$i}/";
146
-        $entryArray += [
147
-            $entryKey => [
148
-                'lastmod' => (new DateTime($mostRecentBlogTagPost['date']))->format('Y-m-d'),
149
-                'changefreq' => 'daily',
150
-                'priority' => .1,
151
-            ]
152
-        ];
153
-    }
126
+	$blogPostsWithTag = $blogPostRepository->getActivePostsByTag($blogTag['id']);
127
+	if (count($blogPostsWithTag) < 1) {
128
+		continue;
129
+	}
130
+
131
+	$mostRecentBlogTagPost = array_reduce($blogPostsWithTag, $reduceToMostRecentBlogPost);
132
+
133
+	$blogTagPath = str_replace(' ', '-', $blogTag['tag']);
134
+	$entryKey = "/tag/{$blogTagPath}/";
135
+	$entryArray += [
136
+		$entryKey => [
137
+			'lastmod' => (new DateTime($mostRecentBlogTagPost['date']))->format('Y-m-d'),
138
+			'changefreq' => 'daily',
139
+			'priority' => .1,
140
+		]
141
+	];
142
+
143
+	for ($i = 2; (($i - 1) * $blogPostsPerPage) < count($blogPostsWithTag); $i++) {
144
+		$blogTagPath = str_replace(' ', '-', $blogTag['tag']);
145
+		$entryKey = "/tag/{$blogTagPath}/{$i}/";
146
+		$entryArray += [
147
+			$entryKey => [
148
+				'lastmod' => (new DateTime($mostRecentBlogTagPost['date']))->format('Y-m-d'),
149
+				'changefreq' => 'daily',
150
+				'priority' => .1,
151
+			]
152
+		];
153
+	}
154 154
 }
155 155
 
156 156
 $reversedBlogPosts = array_reverse($activeBlogPosts);
157 157
 foreach ($reversedBlogPosts as $blogPost) {
158
-    $entryKey = "/{$blogPost['category']}/{$blogPost['path']}/";
159
-    $entryArray += [
160
-        $entryKey => [
161
-            'lastmod' => (new DateTime($blogPost['date']))->format('Y-m-d'), // todo this should be based on comment
162
-            'changefreq' => 'weekly',
163
-            'priority' => .8,
164
-        ],
165
-    ];
158
+	$entryKey = "/{$blogPost['category']}/{$blogPost['path']}/";
159
+	$entryArray += [
160
+		$entryKey => [
161
+			'lastmod' => (new DateTime($blogPost['date']))->format('Y-m-d'), // todo this should be based on comment
162
+			'changefreq' => 'weekly',
163
+			'priority' => .8,
164
+		],
165
+	];
166 166
 }
167 167
 
168 168
 $entryArray += [
169
-    '/about/' => [
170
-        'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
171
-        'changefreq' => 'monthly',
172
-        'priority' => .2,
173
-    ]
169
+	'/about/' => [
170
+		'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
171
+		'changefreq' => 'monthly',
172
+		'priority' => .2,
173
+	]
174 174
 ];
175 175
 
176 176
 $buildSitemap($entryArray, 'http://blog.jacobemerick.com', 'blog');
@@ -184,21 +184,21 @@  discard block
 block discarded – undo
184 184
 $mostRecentPost = current($mostRecentPost);
185 185
 
186 186
 $entryArray = [
187
-    '/' => [
188
-        'lastmod' => (new DateTime($mostRecentPost['date']))->format('Y-m-d'),
189
-        'changefreq' => 'daily',
190
-        'priority' => 1,
191
-    ],
192
-    '/about/' => [
193
-        'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
194
-        'changefreq' => 'monthly',
195
-        'priority' => .4,
196
-    ],
197
-    '/contact/' => [
198
-        'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
199
-        'changefreq' => 'monthly',
200
-        'priority' => .3,
201
-    ],
187
+	'/' => [
188
+		'lastmod' => (new DateTime($mostRecentPost['date']))->format('Y-m-d'),
189
+		'changefreq' => 'daily',
190
+		'priority' => 1,
191
+	],
192
+	'/about/' => [
193
+		'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
194
+		'changefreq' => 'monthly',
195
+		'priority' => .4,
196
+	],
197
+	'/contact/' => [
198
+		'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
199
+		'changefreq' => 'monthly',
200
+		'priority' => .3,
201
+	],
202 202
 ];
203 203
 
204 204
 $buildSitemap($entryArray, 'http://home.jacobemerick.com', 'home');
@@ -208,12 +208,12 @@  discard block
 block discarded – undo
208 208
  * lifestream.jacobemerick.com
209 209
  *********************************************/
210 210
 $reduceToMostRecentStreamActivity = function ($recentActivity, $activity) {
211
-    if (is_null($recentActivity)) {
212
-        return $activity;
213
-    }
214
-    $activityDate = new DateTime($activity['datetime']);
215
-    $recentActivityDate = new DateTime($recentActivity['datetime']);
216
-    return ($activityDate > $recentActivityDate) ? $activity: $recentActivity;
211
+	if (is_null($recentActivity)) {
212
+		return $activity;
213
+	}
214
+	$activityDate = new DateTime($activity['datetime']);
215
+	$recentActivityDate = new DateTime($recentActivity['datetime']);
216
+	return ($activityDate > $recentActivityDate) ? $activity: $recentActivity;
217 217
 };
218 218
 
219 219
 $streamActivitiesPerPage = 15;
@@ -223,78 +223,78 @@  discard block
 block discarded – undo
223 223
 $mostRecentStreamActivity = array_reduce($streamActivities, $reduceToMostRecentStreamActivity);
224 224
 
225 225
 $entryArray = [
226
-    '/' => [
227
-        'lastmod' => (new DateTime($mostRecentStreamActivity['datetime']))->format('c'),
228
-        'changefreq' => 'hourly',
229
-        'priority' => .9,
230
-    ]
226
+	'/' => [
227
+		'lastmod' => (new DateTime($mostRecentStreamActivity['datetime']))->format('c'),
228
+		'changefreq' => 'hourly',
229
+		'priority' => .9,
230
+	]
231 231
 ];
232 232
 for ($i = 2; (($i - 1) * $streamActivitiesPerPage) < count($streamActivities); $i++) {
233
-    $entryKey = "/page/{$i}/";
234
-    $entryArray += [
235
-        $entryKey => [
236
-            'lastmod' => (new DateTime($mostRecentStreamActivity['datetime']))->format('c'),
237
-            'changefreq' => 'hourly',
238
-            'priority' => .1,
239
-        ]
240
-    ];
233
+	$entryKey = "/page/{$i}/";
234
+	$entryArray += [
235
+		$entryKey => [
236
+			'lastmod' => (new DateTime($mostRecentStreamActivity['datetime']))->format('c'),
237
+			'changefreq' => 'hourly',
238
+			'priority' => .1,
239
+		]
240
+	];
241 241
 }
242 242
 
243 243
 $streamTypeArray = [
244
-    'blog',
245
-    'books',
246
-    'distance',
247
-    'github',
248
-    'hulu',
249
-    'twitter',
250
-    'youtube',
244
+	'blog',
245
+	'books',
246
+	'distance',
247
+	'github',
248
+	'hulu',
249
+	'twitter',
250
+	'youtube',
251 251
 ];
252 252
 
253 253
 foreach ($streamTypeArray as $streamType) {
254
-    $streamTypeActivities = array_filter($streamActivities, function ($post) use ($streamType) {
255
-        return $post['type'] == $streamType;
256
-    });
257
-    $mostRecentStreamTypeActivity = array_reduce($streamTypeActivities, $reduceToMostRecentStreamActivity);
258
-
259
-    $entryKey = "/{$streamType}/";
260
-    $entryArray += [
261
-        $entryKey => [
262
-            'lastmod' => (new DateTime($mostRecentStreamTypeActivity['datetime']))->format('c'),
263
-            'changefreq' => 'hourly',
264
-            'priority' => .3,
265
-        ]
266
-    ];
267
-
268
-    for ($i = 2; (($i - 1) * $streamActivitiesPerPage) < count($streamTypeActivities); $i++) {
269
-        $entryKey = "/{$streamType}/page/{$i}/";
270
-        $entryArray += [
271
-            $entryKey => [
272
-                'lastmod' => (new DateTime($mostRecentStreamTypeActivity['datetime']))->format('c'),
273
-                'changefreq' => 'hourly',
274
-                'priority' => .1,
275
-            ]
276
-        ];
277
-    }
254
+	$streamTypeActivities = array_filter($streamActivities, function ($post) use ($streamType) {
255
+		return $post['type'] == $streamType;
256
+	});
257
+	$mostRecentStreamTypeActivity = array_reduce($streamTypeActivities, $reduceToMostRecentStreamActivity);
258
+
259
+	$entryKey = "/{$streamType}/";
260
+	$entryArray += [
261
+		$entryKey => [
262
+			'lastmod' => (new DateTime($mostRecentStreamTypeActivity['datetime']))->format('c'),
263
+			'changefreq' => 'hourly',
264
+			'priority' => .3,
265
+		]
266
+	];
267
+
268
+	for ($i = 2; (($i - 1) * $streamActivitiesPerPage) < count($streamTypeActivities); $i++) {
269
+		$entryKey = "/{$streamType}/page/{$i}/";
270
+		$entryArray += [
271
+			$entryKey => [
272
+				'lastmod' => (new DateTime($mostRecentStreamTypeActivity['datetime']))->format('c'),
273
+				'changefreq' => 'hourly',
274
+				'priority' => .1,
275
+			]
276
+		];
277
+	}
278 278
 }
279 279
 
280 280
 $reversedStreamActivities = array_reverse($streamActivities);
281 281
 foreach ($reversedStreamActivities as $streamActivity) {
282
-    $entryKey = "/{$streamActivity['type']}/{$streamActivity['id']}/";
283
-    $entryArray += [
284
-        $entryKey => [
285
-            'lastmod' => (new DateTime($streamActivity['datetime']))->format('c'),
286
-            'changefreq' => 'never',
287
-            'priority' => .5,
288
-        ],
289
-    ];
282
+	$entryKey = "/{$streamActivity['type']}/{$streamActivity['id']}/";
283
+	$entryArray += [
284
+		$entryKey => [
285
+			'lastmod' => (new DateTime($streamActivity['datetime']))->format('c'),
286
+			'changefreq' => 'never',
287
+			'priority' => .5,
288
+		],
289
+	];
290 290
 }
291 291
 
292 292
 $entryArray += [
293
-    '/about/' => [
294
-        'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
295
-        'changefreq' => 'monthly',
296
-        'priority' => .7,
297
-    ]
293
+	'/about/' => [
294
+		'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
295
+		'changefreq' => 'monthly',
296
+		'priority' => .7,
297
+	]
298 298
 ];
299 299
 
300 300
 $buildSitemap($entryArray, 'http://lifestream.jacobemerick.com', 'lifestream');
@@ -307,43 +307,43 @@  discard block
 block discarded – undo
307 307
 $portfolioPieces = $portfolioRepository->getPieces();
308 308
 
309 309
 $entryArray = [
310
-    '/' => [
311
-        'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
312
-        'changefreq' => 'weekly',
313
-        'priority' => 1,
314
-    ],
315
-    '/print/' => [
316
-        'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
317
-        'changefreq' => 'never',
318
-        'priority' => .1,
319
-    ],
320
-    '/web/' => [
321
-        'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
322
-        'changefreq' => 'never',
323
-        'priority' => .1,
324
-    ],
325
-    '/contact/' => [
326
-        'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
327
-        'changefreq' => 'never',
328
-        'priority' => .4,
329
-    ],
330
-    '/resume/' => [
331
-        'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
332
-        'changefreq' => 'yearly',
333
-        'priority' => .9,
334
-    ],
310
+	'/' => [
311
+		'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
312
+		'changefreq' => 'weekly',
313
+		'priority' => 1,
314
+	],
315
+	'/print/' => [
316
+		'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
317
+		'changefreq' => 'never',
318
+		'priority' => .1,
319
+	],
320
+	'/web/' => [
321
+		'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
322
+		'changefreq' => 'never',
323
+		'priority' => .1,
324
+	],
325
+	'/contact/' => [
326
+		'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
327
+		'changefreq' => 'never',
328
+		'priority' => .4,
329
+	],
330
+	'/resume/' => [
331
+		'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
332
+		'changefreq' => 'yearly',
333
+		'priority' => .9,
334
+	],
335 335
 ];
336 336
 
337 337
 foreach ($portfolioPieces as $portfolioPiece) {
338
-    $portfolioCategory = ($portfolioPiece['category'] == 1) ? 'web' : 'print';
339
-    $entryKey = "/{$portfolioCategory}/{$portfolioPiece['title_url']}/";
340
-    $entryArray += [
341
-        $entryKey => [
342
-            'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
343
-            'changefreq' => 'never',
344
-            'priority' => .7,
345
-        ],
346
-    ];
338
+	$portfolioCategory = ($portfolioPiece['category'] == 1) ? 'web' : 'print';
339
+	$entryKey = "/{$portfolioCategory}/{$portfolioPiece['title_url']}/";
340
+	$entryArray += [
341
+		$entryKey => [
342
+			'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
343
+			'changefreq' => 'never',
344
+			'priority' => .7,
345
+		],
346
+	];
347 347
 }
348 348
 
349 349
 $buildSitemap($entryArray, 'http://portfolio.jacobemerick.com', 'portfolio');
@@ -357,26 +357,26 @@  discard block
 block discarded – undo
357 357
 $mostRecentChange = current($mostRecentChange);
358 358
 
359 359
 $entryArray = [
360
-    '/' => [
361
-        'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
362
-        'changefreq' => 'weekly',
363
-        'priority' => 1,
364
-    ],
365
-    '/terms/' => [
366
-        'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
367
-        'changefreq' => 'weekly',
368
-        'priority' => .3,
369
-    ],
370
-    '/change-log/' => [
371
-        'lastmod' => (new DateTime($mostRecentChange['datetime']))->format('c'),
372
-        'changefreq' => 'daily',
373
-        'priority' => .1,
374
-    ],
375
-    '/contact/' => [
376
-        'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
377
-        'changefreq' => 'weekly',
378
-        'priority' => .6,
379
-    ],
360
+	'/' => [
361
+		'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
362
+		'changefreq' => 'weekly',
363
+		'priority' => 1,
364
+	],
365
+	'/terms/' => [
366
+		'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
367
+		'changefreq' => 'weekly',
368
+		'priority' => .3,
369
+	],
370
+	'/change-log/' => [
371
+		'lastmod' => (new DateTime($mostRecentChange['datetime']))->format('c'),
372
+		'changefreq' => 'daily',
373
+		'priority' => .1,
374
+	],
375
+	'/contact/' => [
376
+		'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
377
+		'changefreq' => 'weekly',
378
+		'priority' => .6,
379
+	],
380 380
 ];
381 381
 
382 382
 $buildSitemap($entryArray, 'http://site.jacobemerick.com', 'site');
@@ -386,108 +386,108 @@  discard block
 block discarded – undo
386 386
  * www.waterfallofthekeweenaw.com
387 387
  *********************************************/
388 388
 $reduceToMostRecentJournalLog = function ($recentLog, $log) {
389
-    if (is_null($recentLog)) {
390
-        return $log;
391
-    }
392
-    $logDate = new DateTime($log['publish_date']);
393
-    $recentLogDate = new DateTime($recentLog['publish_date']);
394
-    return ($logDate > $recentLogDate) ? log: $recentLog;
389
+	if (is_null($recentLog)) {
390
+		return $log;
391
+	}
392
+	$logDate = new DateTime($log['publish_date']);
393
+	$recentLogDate = new DateTime($recentLog['publish_date']);
394
+	return ($logDate > $recentLogDate) ? log: $recentLog;
395 395
 };
396 396
 
397 397
 $waterfallRepository = new WaterfallRepository($container['db_connection_locator']);
398 398
 $waterfallList = $waterfallRepository->getWaterfalls();
399 399
 
400 400
 $entryArray = [
401
-    '/' => [
402
-        'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
403
-        'changefreq' => 'daily',
404
-        'priority' => 1,
405
-    ],
406
-    '/falls/' => [
407
-        'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
408
-        'changefreq' => 'weekly',
409
-        'priority' => .3,
410
-    ],
401
+	'/' => [
402
+		'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
403
+		'changefreq' => 'daily',
404
+		'priority' => 1,
405
+	],
406
+	'/falls/' => [
407
+		'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
408
+		'changefreq' => 'weekly',
409
+		'priority' => .3,
410
+	],
411 411
 ];
412 412
 
413 413
 for ($i = 2; (($i - 1) * 24) < count($waterfallList); $i++) {
414
-    $entryKey = "/falls/{$i}/";
415
-    $entryArray += [
416
-        $entryKey => [
417
-            'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
418
-            'changefreq' => 'weekly',
419
-            'priority' => .1,
420
-        ]
421
-    ];
414
+	$entryKey = "/falls/{$i}/";
415
+	$entryArray += [
416
+		$entryKey => [
417
+			'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
418
+			'changefreq' => 'weekly',
419
+			'priority' => .1,
420
+		]
421
+	];
422 422
 }
423 423
 
424 424
 $waterfallCountyRepository = new WaterfallCountyRepository($container['db_connection_locator']);
425 425
 $waterfallCountyList = $waterfallCountyRepository->getCountyList();
426 426
 
427 427
 foreach ($waterfallCountyList as $waterfallCounty) {
428
-    $entryKey = "/{$waterfallCounty['alias']}/";
429
-    $entryArray += [
430
-        $entryKey => [
431
-            'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
432
-            'changefreq' => 'monthly',
433
-            'priority' => .6
434
-        ]
435
-    ];
436
-
437
-    for ($i = 2; (($i - 1) * 12) < $waterfallCounty['count']; $i++) {
438
-        $entryKey = "/{$waterfallCounty['alias']}/{$i}/";
439
-        $entryArray += [
440
-            $entryKey => [
441
-                'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
442
-                'changefreq' => 'monthly',
443
-                'priority' => .1
444
-            ]
445
-        ];
446
-    }
428
+	$entryKey = "/{$waterfallCounty['alias']}/";
429
+	$entryArray += [
430
+		$entryKey => [
431
+			'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
432
+			'changefreq' => 'monthly',
433
+			'priority' => .6
434
+		]
435
+	];
436
+
437
+	for ($i = 2; (($i - 1) * 12) < $waterfallCounty['count']; $i++) {
438
+		$entryKey = "/{$waterfallCounty['alias']}/{$i}/";
439
+		$entryArray += [
440
+			$entryKey => [
441
+				'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
442
+				'changefreq' => 'monthly',
443
+				'priority' => .1
444
+			]
445
+		];
446
+	}
447 447
 }
448 448
 
449 449
 $waterfallWatercourseRepository = new WaterfallWatercourseRepository($container['db_connection_locator']);
450 450
 $waterfallWatercourseList = $waterfallWatercourseRepository->getWatercourseList();
451 451
 
452 452
 foreach ($waterfallWatercourseList as $waterfallWatercourse) {
453
-    $entryKey = "/{$waterfallWatercourse['alias']}/";
454
-    $entryArray += [
455
-        $entryKey => [
456
-            'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
457
-            'changefreq' => 'monthly',
458
-            'priority' => .6
459
-        ]
460
-    ];
461
-
462
-    for ($i = 2; (($i - 1) * 12) < $waterfallWatercourse['count']; $i++) {
463
-        $entryKey = "/{$waterfallWatercourse['alias']}/{$i}/";
464
-        $entryArray += [
465
-            $entryKey => [
466
-                'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
467
-                'changefreq' => 'monthly',
468
-                'priority' => .1
469
-            ]
470
-        ];
471
-    }
453
+	$entryKey = "/{$waterfallWatercourse['alias']}/";
454
+	$entryArray += [
455
+		$entryKey => [
456
+			'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
457
+			'changefreq' => 'monthly',
458
+			'priority' => .6
459
+		]
460
+	];
461
+
462
+	for ($i = 2; (($i - 1) * 12) < $waterfallWatercourse['count']; $i++) {
463
+		$entryKey = "/{$waterfallWatercourse['alias']}/{$i}/";
464
+		$entryArray += [
465
+			$entryKey => [
466
+				'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
467
+				'changefreq' => 'monthly',
468
+				'priority' => .1
469
+			]
470
+		];
471
+	}
472 472
 }
473 473
 
474 474
 foreach ($waterfallList as $waterfall) {
475
-    $entryKey = "/{$waterfall['watercourse_alias']}/{$waterfall['alias']}/";
476
-    $entryArray += [
477
-        $entryKey => [
478
-            'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
479
-            'changefreq' => 'weekly',
480
-            'priority' => .8,
481
-        ],
482
-    ];
475
+	$entryKey = "/{$waterfall['watercourse_alias']}/{$waterfall['alias']}/";
476
+	$entryArray += [
477
+		$entryKey => [
478
+			'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
479
+			'changefreq' => 'weekly',
480
+			'priority' => .8,
481
+		],
482
+	];
483 483
 }
484 484
 
485 485
 $entryArray += [
486
-    '/map/' => [
487
-        'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
488
-        'changefreq' => 'monthly',
489
-        'priority' => .6,
490
-    ]
486
+	'/map/' => [
487
+		'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
488
+		'changefreq' => 'monthly',
489
+		'priority' => .6,
490
+	]
491 491
 ];
492 492
 
493 493
 $waterfallLogRepository = new WaterfallLogRepository($container['db_connection_locator']);
@@ -496,91 +496,91 @@  discard block
 block discarded – undo
496 496
 $mostRecentWaterfallLog = array_reduce($activeWaterfallLogs, $reduceToMostRecentJournalLog);
497 497
 
498 498
 $entryArray += [
499
-    '/journal/' => [
500
-        'lastmod' => (new DateTime($mostRecentWaterfallLog['publish_date']))->format('c'),
501
-        'changefreq' => 'weekly',
502
-        'priority' => .3,
503
-    ],
499
+	'/journal/' => [
500
+		'lastmod' => (new DateTime($mostRecentWaterfallLog['publish_date']))->format('c'),
501
+		'changefreq' => 'weekly',
502
+		'priority' => .3,
503
+	],
504 504
 ];
505 505
 
506 506
 for ($i = 2; (($i - 1) * 10) < count($activeWaterfallLogs); $i++) {
507
-    $entryKey = "/journal/{$i}/";
508
-    $entryArray += [
509
-        $entryKey => [
510
-            'lastmod' => (new DateTime($mostRecentWaterfallLog['publish_date']))->format('c'),
511
-            'changefreq' => 'weekly',
512
-            'priority' => .1,
513
-        ]
514
-    ];
507
+	$entryKey = "/journal/{$i}/";
508
+	$entryArray += [
509
+		$entryKey => [
510
+			'lastmod' => (new DateTime($mostRecentWaterfallLog['publish_date']))->format('c'),
511
+			'changefreq' => 'weekly',
512
+			'priority' => .1,
513
+		]
514
+	];
515 515
 }
516 516
 
517 517
 $waterfallCompanionRepository = new WaterfallCompanionRepository($container['db_connection_locator']);
518 518
 $waterfallCompanionList = $waterfallCompanionRepository->getCompanionList();
519 519
 
520 520
 foreach ($waterfallCompanionList as $waterfallCompanion) {
521
-    $entryKey = "/companion/{$waterfallCompanion['alias']}/";
522
-    $entryArray += [
523
-        $entryKey => [
524
-            'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'), // todo based on log
525
-            'changefreq' => 'monthly',
526
-            'priority' => .2
527
-        ]
528
-    ];
529
-
530
-    for ($i = 2; (($i - 1) * 10) < $waterfallCompanion['count']; $i++) {
531
-        $entryKey = "/companion/{$waterfallCompanion['alias']}/{$i}/";
532
-        $entryArray += [
533
-            $entryKey => [
534
-                'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
535
-                'changefreq' => 'monthly',
536
-                'priority' => .1
537
-            ]
538
-        ];
539
-    }
521
+	$entryKey = "/companion/{$waterfallCompanion['alias']}/";
522
+	$entryArray += [
523
+		$entryKey => [
524
+			'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'), // todo based on log
525
+			'changefreq' => 'monthly',
526
+			'priority' => .2
527
+		]
528
+	];
529
+
530
+	for ($i = 2; (($i - 1) * 10) < $waterfallCompanion['count']; $i++) {
531
+		$entryKey = "/companion/{$waterfallCompanion['alias']}/{$i}/";
532
+		$entryArray += [
533
+			$entryKey => [
534
+				'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
535
+				'changefreq' => 'monthly',
536
+				'priority' => .1
537
+			]
538
+		];
539
+	}
540 540
 }
541 541
 
542 542
 $waterfallPeriodRepository = new WaterfallPeriodRepository($container['db_connection_locator']);
543 543
 $waterfallPeriodList = $waterfallPeriodRepository->getPeriodList();
544 544
 
545 545
 foreach ($waterfallPeriodList as $waterfallPeriod) {
546
-    $entryKey = "/period/{$waterfallPeriod['alias']}/";
547
-    $entryArray += [
548
-        $entryKey => [
549
-            'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'), // todo based on log
550
-            'changefreq' => 'monthly',
551
-            'priority' => .2
552
-        ]
553
-    ];
554
-
555
-    for ($i = 2; (($i - 1) * 10) < $waterfallPeriod['count']; $i++) {
556
-        $entryKey = "/period/{$waterfallPeriod['alias']}/{$i}/";
557
-        $entryArray += [
558
-            $entryKey => [
559
-                'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
560
-                'changefreq' => 'monthly',
561
-                'priority' => .1
562
-            ]
563
-        ];
564
-    }
546
+	$entryKey = "/period/{$waterfallPeriod['alias']}/";
547
+	$entryArray += [
548
+		$entryKey => [
549
+			'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'), // todo based on log
550
+			'changefreq' => 'monthly',
551
+			'priority' => .2
552
+		]
553
+	];
554
+
555
+	for ($i = 2; (($i - 1) * 10) < $waterfallPeriod['count']; $i++) {
556
+		$entryKey = "/period/{$waterfallPeriod['alias']}/{$i}/";
557
+		$entryArray += [
558
+			$entryKey => [
559
+				'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
560
+				'changefreq' => 'monthly',
561
+				'priority' => .1
562
+			]
563
+		];
564
+	}
565 565
 }
566 566
 
567 567
 foreach ($activeWaterfallLogs as $waterfallLog) {
568
-    $entryKey = "/journal/{$waterfallLog['alias']}/";
569
-    $entryArray += [
570
-        $entryKey => [
571
-            'lastmod' => (new DateTime($waterfallLog['publish_date']))->format('c'),
572
-            'changefreq' => 'weekly',
573
-            'priority' => .4,
574
-        ],
575
-    ];
568
+	$entryKey = "/journal/{$waterfallLog['alias']}/";
569
+	$entryArray += [
570
+		$entryKey => [
571
+			'lastmod' => (new DateTime($waterfallLog['publish_date']))->format('c'),
572
+			'changefreq' => 'weekly',
573
+			'priority' => .4,
574
+		],
575
+	];
576 576
 }
577 577
 
578 578
 $entryArray += [
579
-    '/about/' => [
580
-        'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
581
-        'changefreq' => 'monthly',
582
-        'priority' => .6,
583
-    ]
579
+	'/about/' => [
580
+		'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'),
581
+		'changefreq' => 'monthly',
582
+		'priority' => .6,
583
+	]
584 584
 ];
585 585
 
586 586
 $buildSitemap($entryArray, 'http://www.waterfallsofthekeweenaw.com', 'waterfalls');
Please login to merge, or discard this patch.
src/Domain/Stream/Blog/MysqlBlogRepository.php 1 patch
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -8,85 +8,85 @@
 block discarded – undo
8 8
 class MysqlBlogRepository implements BlogRepositoryInterface
9 9
 {
10 10
 
11
-    /** @var  ConnectionLocator */
12
-    protected $connections;
11
+	/** @var  ConnectionLocator */
12
+	protected $connections;
13 13
 
14
-    /**
15
-     * @param ConnectonLocator $connections
16
-     */
17
-    public function __construct(ConnectionLocator $connections)
18
-    {
19
-        $this->connections = $connections;
20
-    }
14
+	/**
15
+	 * @param ConnectonLocator $connections
16
+	 */
17
+	public function __construct(ConnectionLocator $connections)
18
+	{
19
+		$this->connections = $connections;
20
+	}
21 21
 
22
-    public function getBlogByPermalink($permalink)
23
-    {
24
-        $query = "
22
+	public function getBlogByPermalink($permalink)
23
+	{
24
+		$query = "
25 25
             SELECT *
26 26
             FROM `jpemeric_stream`.`blog2`
27 27
             WHERE `permalink` = :permalink
28 28
             LIMIT 1";
29
-        $bindings = [
30
-            'permalink' => $permalink,
31
-        ];
29
+		$bindings = [
30
+			'permalink' => $permalink,
31
+		];
32 32
 
33
-        return $this
34
-            ->connections
35
-            ->getRead()
36
-            ->fetchOne($query, $bindings);
37
-    }
33
+		return $this
34
+			->connections
35
+			->getRead()
36
+			->fetchOne($query, $bindings);
37
+	}
38 38
 
39
-    public function getBlogs($limit = null, $offset = 0)
40
-    {
41
-        $query = "
39
+	public function getBlogs($limit = null, $offset = 0)
40
+	{
41
+		$query = "
42 42
             SELECT `id`, `permalink`, `datetime`
43 43
             FROM `jpemeric_stream`.`blog2`
44 44
             ORDER BY `datetime` DESC";
45
-        if (!is_null($limit)) {
46
-            $query .= "
45
+		if (!is_null($limit)) {
46
+			$query .= "
47 47
             LIMIT {$limit}, {$offset}";
48
-        }
48
+		}
49 49
 
50
-        return $this
51
-            ->connections
52
-            ->getRead()
53
-            ->fetchAll($query);
54
-    }
50
+		return $this
51
+			->connections
52
+			->getRead()
53
+			->fetchAll($query);
54
+	}
55 55
 
56
-    public function getBlogsUpdatedSince(DateTime $datetime)
57
-    {
58
-        $query = "
56
+	public function getBlogsUpdatedSince(DateTime $datetime)
57
+	{
58
+		$query = "
59 59
             SELECT *
60 60
             FROM `jpemeric_stream`.`blog2`
61 61
             WHERE `updated_at` >= :last_update";
62 62
 
63
-        $bindings = [
64
-            'last_update' => $datetime->format('Y-m-d H:i:s'),
65
-        ];
63
+		$bindings = [
64
+			'last_update' => $datetime->format('Y-m-d H:i:s'),
65
+		];
66 66
 
67
-        return $this
68
-            ->connections
69
-            ->getRead()
70
-            ->fetchAll($query, $bindings);
71
-    }
67
+		return $this
68
+			->connections
69
+			->getRead()
70
+			->fetchAll($query, $bindings);
71
+	}
72 72
 
73
-    public function insertBlog($permalink, DateTime $datetime, array $metadata)
74
-    {
75
-        $query = "
73
+	public function insertBlog($permalink, DateTime $datetime, array $metadata)
74
+	{
75
+		$query = "
76 76
             INSERT INTO `jpemeric_stream`.`blog2`
77 77
                 (`permalink`, `datetime`, `metadata`)
78 78
             VALUES
79 79
                 (:permalink, :datetime, :metadata)";
80 80
 
81
-        $bindings = [
82
-            'permalink' => $permalink,
83
-            'datetime' => $datetime->format('Y-m-d H:i:s'),
84
-            'metadata' => json_encode($metadata),
85
-        ];
81
+		$bindings = [
82
+			'permalink' => $permalink,
83
+			'datetime' => $datetime->format('Y-m-d H:i:s'),
84
+			'metadata' => json_encode($metadata),
85
+		];
86 86
 
87
-        return $this
88
-            ->connections
89
-            ->getWrite()
90
-            ->perform($query, $bindings);
91
-    }
87
+		return $this
88
+			->connections
89
+			->getWrite()
90
+			->perform($query, $bindings);
91
+	}
92 92
 }
Please login to merge, or discard this patch.
src/Domain/Stream/Twitter/MysqlTwitterRepository.php 1 patch
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -8,87 +8,87 @@
 block discarded – undo
8 8
 class MysqlTwitterRepository implements TwitterRepositoryInterface
9 9
 {
10 10
 
11
-    /** @var  ConnectionLocator */
12
-    protected $connections;
13
-
14
-    /**
15
-     * @param ConnectonLocator $connections
16
-     */
17
-    public function __construct(ConnectionLocator $connections)
18
-    {
19
-        $this->connections = $connections;
20
-    }
21
-
22
-    public function getTwitterByTweetId($tweetId)
23
-    {
24
-        $query = "
11
+	/** @var  ConnectionLocator */
12
+	protected $connections;
13
+
14
+	/**
15
+	 * @param ConnectonLocator $connections
16
+	 */
17
+	public function __construct(ConnectionLocator $connections)
18
+	{
19
+		$this->connections = $connections;
20
+	}
21
+
22
+	public function getTwitterByTweetId($tweetId)
23
+	{
24
+		$query = "
25 25
             SELECT `id`, `tweet_id`, `datetime`, `metadata`
26 26
             FROM `jpemeric_stream`.`twitter2`
27 27
             WHERE `tweet_id` = :tweet_id
28 28
             LIMIT 1";
29 29
 
30
-        $bindings = [
31
-            'tweet_id' => $tweetId,
32
-        ];
30
+		$bindings = [
31
+			'tweet_id' => $tweetId,
32
+		];
33 33
 
34
-        return $this
35
-            ->connections
36
-            ->getRead()
37
-            ->fetchOne($query, $bindings);
38
-    }
34
+		return $this
35
+			->connections
36
+			->getRead()
37
+			->fetchOne($query, $bindings);
38
+	}
39 39
 
40
-    public function getTwittersUpdatedSince(DateTime $datetime)
41
-    {
42
-        $query = "
40
+	public function getTwittersUpdatedSince(DateTime $datetime)
41
+	{
42
+		$query = "
43 43
             SELECT *
44 44
             FROM `jpemeric_stream`.`twitter2`
45 45
             WHERE `updated_at` >= :last_update";
46 46
 
47
-        $bindings = [
48
-            'last_update' => $datetime->format('Y-m-d H:i:s'),
49
-        ];
47
+		$bindings = [
48
+			'last_update' => $datetime->format('Y-m-d H:i:s'),
49
+		];
50 50
 
51
-        return $this
52
-            ->connections
53
-            ->getRead()
54
-            ->fetchAll($query, $bindings);
55
-    }
51
+		return $this
52
+			->connections
53
+			->getRead()
54
+			->fetchAll($query, $bindings);
55
+	}
56 56
 
57
-    public function insertTweet($tweetId, DateTime $datetime, array $metadata)
58
-    {
59
-        $query = "
57
+	public function insertTweet($tweetId, DateTime $datetime, array $metadata)
58
+	{
59
+		$query = "
60 60
             INSERT INTO `jpemeric_stream`.`twitter2`
61 61
                 (`tweet_id`, `datetime`, `metadata`)
62 62
             VALUES
63 63
                 (:tweet_id, :datetime, :metadata)";
64 64
 
65
-        $bindings = [
66
-            'tweet_id' => $tweetId,
67
-            'datetime' => $datetime->format('Y-m-d H:i:s'),
68
-            'metadata' => json_encode($metadata),
69
-        ];
70
-
71
-        return $this
72
-            ->connections
73
-            ->getWrite()
74
-            ->perform($query, $bindings);
75
-    }
76
-
77
-    public function updateTweetMetadata($tweetId, array $metadata)
78
-    {
79
-        $query = "
65
+		$bindings = [
66
+			'tweet_id' => $tweetId,
67
+			'datetime' => $datetime->format('Y-m-d H:i:s'),
68
+			'metadata' => json_encode($metadata),
69
+		];
70
+
71
+		return $this
72
+			->connections
73
+			->getWrite()
74
+			->perform($query, $bindings);
75
+	}
76
+
77
+	public function updateTweetMetadata($tweetId, array $metadata)
78
+	{
79
+		$query = "
80 80
             UPDATE `jpemeric_stream`.`twitter2`
81 81
             SET `metadata` = :metadata
82 82
             WHERE `tweet_id` = :tweet_id";
83 83
 
84
-        $bindings = [
85
-            'metadata' => json_encode($metadata),
86
-            'tweet_id' => $tweetId,
87
-        ];
84
+		$bindings = [
85
+			'metadata' => json_encode($metadata),
86
+			'tweet_id' => $tweetId,
87
+		];
88 88
 
89
-        return $this
90
-            ->connections
91
-            ->getWrite()
92
-            ->perform($query, $bindings);
93
-    }
89
+		return $this
90
+			->connections
91
+			->getWrite()
92
+			->perform($query, $bindings);
93
+	}
94 94
 }
Please login to merge, or discard this patch.
script/cron/build-activity-stream.php 2 patches
Indentation   +436 added lines, -436 removed lines patch added patch discarded remove patch
@@ -11,58 +11,58 @@  discard block
 block discarded – undo
11 11
 
12 12
 $lastBlogActivity = $activityRepository->getActivityLastUpdateByType('blog');
13 13
 if ($lastBlogActivity === false) {
14
-    $lastBlogActivityDateTime = new DateTime('2008-05-03');
14
+	$lastBlogActivityDateTime = new DateTime('2008-05-03');
15 15
 } else {
16
-    $lastBlogActivityDateTime = new DateTime($lastBlogActivity['updated_at']);
17
-    $lastBlogActivityDateTime->modify('-5 days');
16
+	$lastBlogActivityDateTime = new DateTime($lastBlogActivity['updated_at']);
17
+	$lastBlogActivityDateTime->modify('-5 days');
18 18
 }
19 19
 $newBlogActivity = $blogRepository->getBlogsUpdatedSince($lastBlogActivityDateTime);
20 20
 foreach ($newBlogActivity as $blog) {
21
-    $uniqueBlogCheck = $activityRepository->getActivityByTypeId('blog', $blog['id']);
22
-    if ($uniqueBlogCheck !== false) {
23
-        continue;
24
-    }
25
-
26
-    $blogData = json_decode($blog['metadata'], true);
27
-    $message = sprintf(
28
-        'Blogged about %s | %s.',
29
-        str_replace('-', ' ', $blogData['category']),
30
-        $blogData['title']
31
-    );
32
-
33
-    if (isset($blogData['enclosure'])) {
34
-        $messageLong = sprintf(
35
-            "<img src=\"%s\" alt=\"Blog | %s\" />\n" .
36
-            "<h4><a href=\"%s\" title=\"Jacob Emerick's Blog | %s\">%s</a></h4>\n" .
37
-            "<p>%s [<a href=\"%s\">read more</a></a>]</p>",
38
-            $blogData['enclosure']['@attributes']['url'],
39
-            $blogData['title'],
40
-            $blogData['link'],
41
-            $blogData['title'],
42
-            $blogData['title'],
43
-            htmlentities($blogData['description']),
44
-            $blogData['link']
45
-        );
46
-    } else {
47
-        $messageLong = sprintf(
48
-            "<h4><a href=\"%s\" title=\"Jacob Emerick's Blog | %s\">%s</a></h4>\n" .
49
-            "<p>%s [<a href=\"%s\">read more</a></a>]</p>",
50
-            $blogData['link'],
51
-            $blogData['title'],
52
-            $blogData['title'],
53
-            htmlentities($blogData['description']),
54
-            $blogData['link']
55
-        );
56
-    }
57
-
58
-    $activityRepository->insertActivity(
59
-        $message,
60
-        $messageLong,
61
-        (new DateTime($blog['datetime'])),
62
-        [],
63
-        'blog',
64
-        $blog['id']
65
-    );
21
+	$uniqueBlogCheck = $activityRepository->getActivityByTypeId('blog', $blog['id']);
22
+	if ($uniqueBlogCheck !== false) {
23
+		continue;
24
+	}
25
+
26
+	$blogData = json_decode($blog['metadata'], true);
27
+	$message = sprintf(
28
+		'Blogged about %s | %s.',
29
+		str_replace('-', ' ', $blogData['category']),
30
+		$blogData['title']
31
+	);
32
+
33
+	if (isset($blogData['enclosure'])) {
34
+		$messageLong = sprintf(
35
+			"<img src=\"%s\" alt=\"Blog | %s\" />\n" .
36
+			"<h4><a href=\"%s\" title=\"Jacob Emerick's Blog | %s\">%s</a></h4>\n" .
37
+			"<p>%s [<a href=\"%s\">read more</a></a>]</p>",
38
+			$blogData['enclosure']['@attributes']['url'],
39
+			$blogData['title'],
40
+			$blogData['link'],
41
+			$blogData['title'],
42
+			$blogData['title'],
43
+			htmlentities($blogData['description']),
44
+			$blogData['link']
45
+		);
46
+	} else {
47
+		$messageLong = sprintf(
48
+			"<h4><a href=\"%s\" title=\"Jacob Emerick's Blog | %s\">%s</a></h4>\n" .
49
+			"<p>%s [<a href=\"%s\">read more</a></a>]</p>",
50
+			$blogData['link'],
51
+			$blogData['title'],
52
+			$blogData['title'],
53
+			htmlentities($blogData['description']),
54
+			$blogData['link']
55
+		);
56
+	}
57
+
58
+	$activityRepository->insertActivity(
59
+		$message,
60
+		$messageLong,
61
+		(new DateTime($blog['datetime'])),
62
+		[],
63
+		'blog',
64
+		$blog['id']
65
+	);
66 66
 }
67 67
 
68 68
 use Jacobemerick\Web\Domain\Stream\BlogComment\MysqlBlogCommentRepository as BlogCommentRepository;
@@ -70,30 +70,30 @@  discard block
 block discarded – undo
70 70
 $blogCommentActivity = $blogCommentRepository->getBlogComments();
71 71
 $blogCommentHolder = [];
72 72
 foreach ($blogCommentActivity as $blogComment) {
73
-    $blogPermalink = $blogComment['permalink'];
74
-    $blogPermalink = explode('#', $blogPermalink);
75
-    $blogPermalink = current($blogPermalink);
76
-
77
-    $blog = $blogRepository->getBlogByPermalink($blogPermalink);
78
-    if (!array_key_exists($blog['id'], $blogCommentHolder)) {
79
-        $blogCommentHolder[$blog['id']] = 1;
80
-    } else {
81
-        $blogCommentHolder[$blog['id']]++;
82
-    }
73
+	$blogPermalink = $blogComment['permalink'];
74
+	$blogPermalink = explode('#', $blogPermalink);
75
+	$blogPermalink = current($blogPermalink);
76
+
77
+	$blog = $blogRepository->getBlogByPermalink($blogPermalink);
78
+	if (!array_key_exists($blog['id'], $blogCommentHolder)) {
79
+		$blogCommentHolder[$blog['id']] = 1;
80
+	} else {
81
+		$blogCommentHolder[$blog['id']]++;
82
+	}
83 83
 }
84 84
 
85 85
 foreach ($blogCommentHolder as $blogId => $commentCount) {
86
-    $blogActivity = $activityRepository->getActivityByTypeId('blog', $blogId);
87
-    $blogActivityMetadata = json_decode($blogActivity['metadata'], true);
88
-    if (
89
-        !isset($blogActivityMetadata['comments']) ||
90
-        $blogActivityMetadata['comments'] != $commentCount
91
-    ) {
92
-        $activityRepository->updateActivityMetadata(
93
-            $blogActivity['id'],
94
-            ['comments' => $commentCount]
95
-        );
96
-    }
86
+	$blogActivity = $activityRepository->getActivityByTypeId('blog', $blogId);
87
+	$blogActivityMetadata = json_decode($blogActivity['metadata'], true);
88
+	if (
89
+		!isset($blogActivityMetadata['comments']) ||
90
+		$blogActivityMetadata['comments'] != $commentCount
91
+	) {
92
+		$activityRepository->updateActivityMetadata(
93
+			$blogActivity['id'],
94
+			['comments' => $commentCount]
95
+		);
96
+	}
97 97
 }
98 98
 
99 99
 // distance
@@ -102,67 +102,67 @@  discard block
 block discarded – undo
102 102
 
103 103
 $lastDailyMileActivity = $activityRepository->getActivityLastUpdateByType('distance');
104 104
 if ($lastDailyMileActivity === false) {
105
-    $lastDailyMileActivityDateTime = new DateTime('2008-05-03');
105
+	$lastDailyMileActivityDateTime = new DateTime('2008-05-03');
106 106
 } else {
107
-    $lastDailyMileActivityDateTime = new DateTime($lastDailyMileActivity['updated_at']);
108
-    $lastDailyMileActivityDateTime->modify('-5 days');
107
+	$lastDailyMileActivityDateTime = new DateTime($lastDailyMileActivity['updated_at']);
108
+	$lastDailyMileActivityDateTime->modify('-5 days');
109 109
 }
110 110
 $newDailyMileActivity = $dailyMileRepository->getDailyMilesUpdatedSince($lastDailyMileActivityDateTime);
111 111
 foreach ($newDailyMileActivity as $dailyMile) {
112
-    $uniqueDailyMileCheck = $activityRepository->getActivityByTypeId('distance', $dailyMile['id']);
113
-    if ($uniqueDailyMileCheck !== false) {
114
-        continue;
115
-    }
116
-
117
-    $dailyMileData = json_decode($dailyMile['metadata'], true);
118
-    if ($dailyMile['type'] == 'Hiking') {
119
-        $message = sprintf(
120
-            '%s %.2f %s and felt %s.',
121
-            'Hiked',
122
-            $dailyMileData['workout']['distance']['value'],
123
-            $dailyMileData['workout']['distance']['units'],
124
-            $dailyMileData['workout']['felt']
125
-        );
126
-        $messageLong = "<p>{$message}</p>";
127
-        if (isset($dailyMileData['workout']['title'])) {
128
-            $messageLong .= "\n<p>I was hiking up around the {$dailyMileData['workout']['title']} area.</p>";
129
-        }
130
-    } else if ($dailyMile['type'] == 'Running') {
131
-        $message = sprintf(
132
-            '%s %.2f %s and felt %s.',
133
-            'Ran',
134
-            $dailyMileData['workout']['distance']['value'],
135
-            $dailyMileData['workout']['distance']['units'],
136
-            $dailyMileData['workout']['felt']
137
-        );
138
-        $messageLong = "<p>{$message}</p>";
139
-        if (isset($dailyMileData['message'])) {
140
-            $messageLong .= "\n<p>Afterwards, I was all like '{$dailyMileData['message']}'.</p>";
141
-        }
142
-    } else if ($dailyMile['type'] == 'Walking') {
143
-        $message = sprintf(
144
-            '%s %.2f %s and felt %s.',
145
-            'Walked',
146
-            $dailyMileData['workout']['distance']['value'],
147
-            $dailyMileData['workout']['distance']['units'],
148
-            $dailyMileData['workout']['felt']
149
-        );
150
-        $messageLong = "<p>{$message}</p>";
151
-        if (isset($dailyMileData['message'])) {
152
-            $messageLong .= "\n<p>{$dailyMileData['message']}</p>";
153
-        }
154
-    } else {
155
-        continue;
156
-    }
157
-
158
-    $activityRepository->insertActivity(
159
-        $message,
160
-        $messageLong,
161
-        (new DateTime($dailyMile['datetime'])),
162
-        [],
163
-        'distance',
164
-        $dailyMile['id']
165
-    );
112
+	$uniqueDailyMileCheck = $activityRepository->getActivityByTypeId('distance', $dailyMile['id']);
113
+	if ($uniqueDailyMileCheck !== false) {
114
+		continue;
115
+	}
116
+
117
+	$dailyMileData = json_decode($dailyMile['metadata'], true);
118
+	if ($dailyMile['type'] == 'Hiking') {
119
+		$message = sprintf(
120
+			'%s %.2f %s and felt %s.',
121
+			'Hiked',
122
+			$dailyMileData['workout']['distance']['value'],
123
+			$dailyMileData['workout']['distance']['units'],
124
+			$dailyMileData['workout']['felt']
125
+		);
126
+		$messageLong = "<p>{$message}</p>";
127
+		if (isset($dailyMileData['workout']['title'])) {
128
+			$messageLong .= "\n<p>I was hiking up around the {$dailyMileData['workout']['title']} area.</p>";
129
+		}
130
+	} else if ($dailyMile['type'] == 'Running') {
131
+		$message = sprintf(
132
+			'%s %.2f %s and felt %s.',
133
+			'Ran',
134
+			$dailyMileData['workout']['distance']['value'],
135
+			$dailyMileData['workout']['distance']['units'],
136
+			$dailyMileData['workout']['felt']
137
+		);
138
+		$messageLong = "<p>{$message}</p>";
139
+		if (isset($dailyMileData['message'])) {
140
+			$messageLong .= "\n<p>Afterwards, I was all like '{$dailyMileData['message']}'.</p>";
141
+		}
142
+	} else if ($dailyMile['type'] == 'Walking') {
143
+		$message = sprintf(
144
+			'%s %.2f %s and felt %s.',
145
+			'Walked',
146
+			$dailyMileData['workout']['distance']['value'],
147
+			$dailyMileData['workout']['distance']['units'],
148
+			$dailyMileData['workout']['felt']
149
+		);
150
+		$messageLong = "<p>{$message}</p>";
151
+		if (isset($dailyMileData['message'])) {
152
+			$messageLong .= "\n<p>{$dailyMileData['message']}</p>";
153
+		}
154
+	} else {
155
+		continue;
156
+	}
157
+
158
+	$activityRepository->insertActivity(
159
+		$message,
160
+		$messageLong,
161
+		(new DateTime($dailyMile['datetime'])),
162
+		[],
163
+		'distance',
164
+		$dailyMile['id']
165
+	);
166 166
 }
167 167
 
168 168
 // github
@@ -171,128 +171,128 @@  discard block
 block discarded – undo
171 171
 
172 172
 $lastGithubActivity = $activityRepository->getActivityLastUpdateByType('github');
173 173
 if ($lastGithubActivity === false) {
174
-    $lastGithubActivityDateTime = new DateTime('2015-10-01');
174
+	$lastGithubActivityDateTime = new DateTime('2015-10-01');
175 175
 } else {
176
-    $lastGithubActivityDateTime = new DateTime($lastGithubActivity['updated_at']);
177
-    $lastGithubActivityDateTime->modify('-5 days');
176
+	$lastGithubActivityDateTime = new DateTime($lastGithubActivity['updated_at']);
177
+	$lastGithubActivityDateTime->modify('-5 days');
178 178
 }
179 179
 
180 180
 $newGithubActivity = $githubRepository->getGithubsUpdatedSince($lastGithubActivityDateTime);
181 181
 foreach ($newGithubActivity as $github) {
182
-    $uniqueGithubCheck = $activityRepository->getActivityByTypeId('github', $github['id']);
183
-    if ($uniqueGithubCheck !== false) {
184
-        continue;
185
-    }
186
-
187
-    $githubData = json_decode($github['metadata'], true);
188
-
189
-    if ($github['type'] == 'CreateEvent') {
190
-        if (
191
-            $githubData['payload']['ref_type'] == 'branch' ||
192
-            $githubData['payload']['ref_type'] == 'tag'
193
-        ) {
194
-            $message = sprintf(
195
-                'Created %s %s at %s.',
196
-                $githubData['payload']['ref_type'],
197
-                $githubData['payload']['ref'],
198
-                $githubData['repo']['name']
199
-            );
200
-            $messageLong = sprintf(
201
-                '<p>Created %s %s at <a href="%s" target="_blank" title="Github | %s">%s</a>.</p>',
202
-                $githubData['payload']['ref_type'],
203
-                $githubData['payload']['ref'],
204
-                "https://github.com/{$githubData['repo']['name']}",
205
-                $githubData['repo']['name'],
206
-                $githubData['repo']['name']
207
-            );
208
-        } else if ($githubData['payload']['ref_type'] == 'repository') {
209
-            $message = sprintf(
210
-                'Created %s %s.',
211
-                $githubData['payload']['ref_type'],
212
-                $githubData['repo']['name']
213
-            );
214
-            $messageLong = sprintf(
215
-                '<p>Created %s <a href="%s" target="_blank" title="Github | %s">%s</a>.</p>',
216
-                $githubData['payload']['ref_type'],
217
-                "https://github.com/{$githubData['repo']['name']}",
218
-                $githubData['repo']['name'],
219
-                $githubData['repo']['name']
220
-            );
221
-        } else {
222
-            continue;
223
-        }
224
-    } else if ($github['type'] == 'ForkEvent') {
225
-        $message = sprintf(
226
-            'Forked %s to %s',
227
-            $githubData['repo']['name'],
228
-            $githubData['payload']['forkee']['full_name']
229
-        );
230
-        $messageLong = sprintf(
231
-            '<p>Forked <a href="%s" target="_blank" title="Github | %s">%s</a> to <a href="%s" target="_blank" title="Github | %s">%s</a>.',
232
-            "https://github.com/{$githubData['repo']['name']}",
233
-            $githubData['repo']['name'],
234
-            $githubData['repo']['name'],
235
-            $githubData['payload']['forkee']['html_url'],
236
-            $githubData['payload']['forkee']['full_name'],
237
-            $githubData['payload']['forkee']['full_name']
238
-        );
239
-    } else if ($github['type'] == 'PullRequestEvent') {
240
-        $message = sprintf(
241
-            '%s a pull request at %s',
242
-            ucwords($githubData['payload']['action']),
243
-            $githubData['repo']['name']
244
-        );
245
-        $messageLong = sprintf(
246
-            '<p>%s pull request <a href="%s" target="_blank" title="Github | %s PR %d">%d</a> at <a href="%s" target="_blank" title="Github | %s">%s</a>.</p>',
247
-            ucwords($githubData['payload']['action']),
248
-            $githubData['payload']['pull_request']['html_url'],
249
-            $githubData['repo']['name'],
250
-            $githubData['payload']['number'],
251
-            $githubData['payload']['number'],
252
-            "https://github.com/{$githubData['repo']['name']}",
253
-            $githubData['repo']['name'],
254
-            $githubData['repo']['name']
255
-        );
256
-    } else if ($github['type'] == 'PushEvent') {
257
-        $message = sprintf(
258
-            'Pushed some code at %s.',
259
-            $githubData['repo']['name']
260
-        );
261
-        $messageLong = sprintf(
262
-            "<p>Pushed some code at <a href=\"%s\" target=\"_blank\" title=\"Github | %s\">%s</a>.</p>\n",
263
-            $githubData['payload']['ref'],
264
-            "https://github.com/{$githubData['repo']['name']}",
265
-            $githubData['repo']['name'],
266
-            $githubData['repo']['name']
267
-        );
268
-        $messageLong .= "<ul>\n";
269
-        foreach ($githubData['payload']['commits'] as $commit) {
270
-            $messageShort = $commit['message'];
271
-            $messageShort = strtok($messageShort, "\n");
272
-            if (strlen($messageShort) > 72) {
273
-                $messageShort = wordwrap($messageShort, 65);
274
-                $messageShort = strtok($messageShort, "\n");
275
-                $messageShort .= '...';
276
-            }
277
-            $messageLong .= sprintf(
278
-                "<li><a href=\"%s\" target=\"_blank\" title=\"Github | %s\">%s</a> %s.</li>\n",
279
-                "https://github.com/{$githubData['repo']['name']}/commit/{$commit['sha']}",
280
-                substr($commit['sha'], 0, 7),
281
-                substr($commit['sha'], 0, 7),
282
-                $messageShort
283
-            );
284
-        }
285
-        $messageLong .= "</ul>";
286
-    }
287
-
288
-    $activityRepository->insertActivity(
289
-        $message,
290
-        $messageLong,
291
-        (new DateTime($github['datetime'])),
292
-        [],
293
-        'github',
294
-        $github['id']
295
-    );
182
+	$uniqueGithubCheck = $activityRepository->getActivityByTypeId('github', $github['id']);
183
+	if ($uniqueGithubCheck !== false) {
184
+		continue;
185
+	}
186
+
187
+	$githubData = json_decode($github['metadata'], true);
188
+
189
+	if ($github['type'] == 'CreateEvent') {
190
+		if (
191
+			$githubData['payload']['ref_type'] == 'branch' ||
192
+			$githubData['payload']['ref_type'] == 'tag'
193
+		) {
194
+			$message = sprintf(
195
+				'Created %s %s at %s.',
196
+				$githubData['payload']['ref_type'],
197
+				$githubData['payload']['ref'],
198
+				$githubData['repo']['name']
199
+			);
200
+			$messageLong = sprintf(
201
+				'<p>Created %s %s at <a href="%s" target="_blank" title="Github | %s">%s</a>.</p>',
202
+				$githubData['payload']['ref_type'],
203
+				$githubData['payload']['ref'],
204
+				"https://github.com/{$githubData['repo']['name']}",
205
+				$githubData['repo']['name'],
206
+				$githubData['repo']['name']
207
+			);
208
+		} else if ($githubData['payload']['ref_type'] == 'repository') {
209
+			$message = sprintf(
210
+				'Created %s %s.',
211
+				$githubData['payload']['ref_type'],
212
+				$githubData['repo']['name']
213
+			);
214
+			$messageLong = sprintf(
215
+				'<p>Created %s <a href="%s" target="_blank" title="Github | %s">%s</a>.</p>',
216
+				$githubData['payload']['ref_type'],
217
+				"https://github.com/{$githubData['repo']['name']}",
218
+				$githubData['repo']['name'],
219
+				$githubData['repo']['name']
220
+			);
221
+		} else {
222
+			continue;
223
+		}
224
+	} else if ($github['type'] == 'ForkEvent') {
225
+		$message = sprintf(
226
+			'Forked %s to %s',
227
+			$githubData['repo']['name'],
228
+			$githubData['payload']['forkee']['full_name']
229
+		);
230
+		$messageLong = sprintf(
231
+			'<p>Forked <a href="%s" target="_blank" title="Github | %s">%s</a> to <a href="%s" target="_blank" title="Github | %s">%s</a>.',
232
+			"https://github.com/{$githubData['repo']['name']}",
233
+			$githubData['repo']['name'],
234
+			$githubData['repo']['name'],
235
+			$githubData['payload']['forkee']['html_url'],
236
+			$githubData['payload']['forkee']['full_name'],
237
+			$githubData['payload']['forkee']['full_name']
238
+		);
239
+	} else if ($github['type'] == 'PullRequestEvent') {
240
+		$message = sprintf(
241
+			'%s a pull request at %s',
242
+			ucwords($githubData['payload']['action']),
243
+			$githubData['repo']['name']
244
+		);
245
+		$messageLong = sprintf(
246
+			'<p>%s pull request <a href="%s" target="_blank" title="Github | %s PR %d">%d</a> at <a href="%s" target="_blank" title="Github | %s">%s</a>.</p>',
247
+			ucwords($githubData['payload']['action']),
248
+			$githubData['payload']['pull_request']['html_url'],
249
+			$githubData['repo']['name'],
250
+			$githubData['payload']['number'],
251
+			$githubData['payload']['number'],
252
+			"https://github.com/{$githubData['repo']['name']}",
253
+			$githubData['repo']['name'],
254
+			$githubData['repo']['name']
255
+		);
256
+	} else if ($github['type'] == 'PushEvent') {
257
+		$message = sprintf(
258
+			'Pushed some code at %s.',
259
+			$githubData['repo']['name']
260
+		);
261
+		$messageLong = sprintf(
262
+			"<p>Pushed some code at <a href=\"%s\" target=\"_blank\" title=\"Github | %s\">%s</a>.</p>\n",
263
+			$githubData['payload']['ref'],
264
+			"https://github.com/{$githubData['repo']['name']}",
265
+			$githubData['repo']['name'],
266
+			$githubData['repo']['name']
267
+		);
268
+		$messageLong .= "<ul>\n";
269
+		foreach ($githubData['payload']['commits'] as $commit) {
270
+			$messageShort = $commit['message'];
271
+			$messageShort = strtok($messageShort, "\n");
272
+			if (strlen($messageShort) > 72) {
273
+				$messageShort = wordwrap($messageShort, 65);
274
+				$messageShort = strtok($messageShort, "\n");
275
+				$messageShort .= '...';
276
+			}
277
+			$messageLong .= sprintf(
278
+				"<li><a href=\"%s\" target=\"_blank\" title=\"Github | %s\">%s</a> %s.</li>\n",
279
+				"https://github.com/{$githubData['repo']['name']}/commit/{$commit['sha']}",
280
+				substr($commit['sha'], 0, 7),
281
+				substr($commit['sha'], 0, 7),
282
+				$messageShort
283
+			);
284
+		}
285
+		$messageLong .= "</ul>";
286
+	}
287
+
288
+	$activityRepository->insertActivity(
289
+		$message,
290
+		$messageLong,
291
+		(new DateTime($github['datetime'])),
292
+		[],
293
+		'github',
294
+		$github['id']
295
+	);
296 296
 }
297 297
 
298 298
 // books
@@ -301,46 +301,46 @@  discard block
 block discarded – undo
301 301
 
302 302
 $lastGoodreadActivity = $activityRepository->getActivityLastUpdateByType('book');
303 303
 if ($lastGoodreadActivity === false) {
304
-    $lastGoodreadActivityDateTime = new DateTime('2010-08-28');
304
+	$lastGoodreadActivityDateTime = new DateTime('2010-08-28');
305 305
 } else {
306
-    $lastGoodreadActivityDateTime = new DateTime($lastGoodreadActivity['updated_at']);
307
-    $lastGoodreadActivityDateTime->modify('-5 days');
306
+	$lastGoodreadActivityDateTime = new DateTime($lastGoodreadActivity['updated_at']);
307
+	$lastGoodreadActivityDateTime->modify('-5 days');
308 308
 }
309 309
 $newGoodreadActivity = $goodreadRepository->getGoodreadsUpdatedSince($lastGoodreadActivityDateTime);
310 310
 foreach ($newGoodreadActivity as $goodread) {
311
-    $uniqueGoodreadCheck = $activityRepository->getActivityByTypeId('book', $goodread['id']);
312
-    if ($uniqueGoodreadCheck !== false) {
313
-        continue;
314
-    }
315
-
316
-    $goodreadData = json_decode($goodread['metadata'], true);
317
-
318
-    if (empty($goodreadData['user_read_at'])) {
319
-        continue;
320
-    }
321
-
322
-    $message = sprintf(
323
-        'Read %s by %s.',
324
-        $goodreadData['title'],
325
-        $goodreadData['author_name']
326
-    );
327
-    if (isset($goodreadData['book_large_image_url'])) {
328
-        $messageLong = sprintf(
329
-            "<img alt=\"Goodreads | %s\" src=\"%s\" />\n",
330
-            $goodreadData['title'],
331
-            $goodreadData['book_large_image_url']
332
-        );
333
-    }
334
-    $messageLong .= "<p>{$message}</p>";
335
-
336
-    $activityRepository->insertActivity(
337
-        $message,
338
-        $messageLong,
339
-        (new DateTime($goodread['datetime'])),
340
-        [],
341
-        'book',
342
-        $goodread['id']
343
-    );
311
+	$uniqueGoodreadCheck = $activityRepository->getActivityByTypeId('book', $goodread['id']);
312
+	if ($uniqueGoodreadCheck !== false) {
313
+		continue;
314
+	}
315
+
316
+	$goodreadData = json_decode($goodread['metadata'], true);
317
+
318
+	if (empty($goodreadData['user_read_at'])) {
319
+		continue;
320
+	}
321
+
322
+	$message = sprintf(
323
+		'Read %s by %s.',
324
+		$goodreadData['title'],
325
+		$goodreadData['author_name']
326
+	);
327
+	if (isset($goodreadData['book_large_image_url'])) {
328
+		$messageLong = sprintf(
329
+			"<img alt=\"Goodreads | %s\" src=\"%s\" />\n",
330
+			$goodreadData['title'],
331
+			$goodreadData['book_large_image_url']
332
+		);
333
+	}
334
+	$messageLong .= "<p>{$message}</p>";
335
+
336
+	$activityRepository->insertActivity(
337
+		$message,
338
+		$messageLong,
339
+		(new DateTime($goodread['datetime'])),
340
+		[],
341
+		'book',
342
+		$goodread['id']
343
+	);
344 344
 }
345 345
 
346 346
 // twitter
@@ -349,136 +349,136 @@  discard block
 block discarded – undo
349 349
 
350 350
 $lastTwitterActivity = $activityRepository->getActivityLastUpdateByType('twitter');
351 351
 if ($lastTwitterActivity === false) {
352
-    $lastTwitterActivityDateTime = new DateTime('2010-03-10');
352
+	$lastTwitterActivityDateTime = new DateTime('2010-03-10');
353 353
 } else {
354
-    $lastTwitterActivityDateTime = new DateTime($lastTwitterActivity['updated_at']);
355
-    $lastTwitterActivityDateTime->modify('-5 days');
354
+	$lastTwitterActivityDateTime = new DateTime($lastTwitterActivity['updated_at']);
355
+	$lastTwitterActivityDateTime->modify('-5 days');
356 356
 }
357 357
 $newTwitterActivity = $twitterRepository->getTwittersUpdatedSince($lastTwitterActivityDateTime);
358 358
 foreach ($newTwitterActivity as $twitter) {
359
-    $twitterData = json_decode($twitter['metadata'], true);
360
-
361
-    $uniqueTwitterCheck = $activityRepository->getActivityByTypeId('twitter', $twitter['id']);
362
-    if ($uniqueTwitterCheck !== false) {
363
-        $metadata = [];
364
-        if ($twitterData['favorite_count'] > 0) {
365
-            $metadata['favorites'] = $twitterData['favorite_count'];
366
-        }
367
-        if ($twitterData['retweet_count'] > 0) {
368
-            $metadata['retweets'] = $twitterData['retweet_count'];
369
-        }
370
-
371
-        $activityRepository->updateActivityMetadata($twitter['id'], $metadata);
372
-        continue;
373
-    }
374
-
375
-    if (
376
-        ($twitterData['in_reply_to_user_id'] != null || substr($twitterData['text'], 0, 1) === '@') &&
377
-        $twitterData['favorite_count'] == 0 &&
378
-        $twitterData['retweet_count'] == 0
379
-    ) {
380
-        continue;
381
-    }
382
-
383
-    $entityHolder = [];
384
-    foreach ($twitterData['entities'] as $entityType => $entities) {
385
-        foreach ($entities as $entity) {
386
-            if ($entityType == 'urls' || $entityType == 'media') {
387
-                $entityHolder[$entity['indices'][0]] = [
388
-                    'start' => $entity['indices'][0],
389
-                    'end' => $entity['indices'][1],
390
-                    'replace' => "[{$entity['display_url']}]"
391
-                ];
392
-            }
393
-        }
394
-    }
395
-
396
-    $message = $twitterData['text'];
397
-    krsort($entityHolder);
398
-    foreach($entityHolder as $entity)
399
-    {
400
-        $message =
401
-            mb_substr($message, 0, $entity['start']) .
402
-            $entity['replace'] .
403
-            mb_substr($message, $entity['end'], null, 'UTF-8');
404
-    }
405
-    $message = mb_convert_encoding($message, 'HTML-ENTITIES', 'UTF-8');
406
-    $message = trim(preg_replace('/\s+/', ' ', $message));
407
-    $message = "Tweeted | {$message}";
408
-
409
-    $entityHolder = [];
410
-    foreach ($twitterData['entities'] as $entityType => $entities) {
411
-        foreach ($entities as $entity) {
412
-            if ($entityType == 'hashtags') {
413
-                $replace = sprintf(
414
-                    '<a href="https://twitter.com/search?q=%%23%s&src=hash" rel="nofollow" target="_blank">#%s</a>',
415
-                    $entity['text'],
416
-                    $entity['text']
417
-                );
418
-            } else if ($entityType == 'urls') {
419
-                $replace = sprintf(
420
-                    '<a href="%s" rel="nofollow" target="_blank" title="%s">%s</a>',
421
-                    $entity['url'],
422
-                    $entity['expanded_url'],
423
-                    $entity['display_url']
424
-                );
425
-            } else if ($entityType == 'user_mentions') {
426
-                $replace = sprintf(
427
-                    '<a href="https://twitter.com/%s" rel="nofollow" target="_blank" title="Twitter | %s">@%s</a>',
428
-                    strtolower($entity['screen_name']),
429
-                    $entity['name'],
430
-                    $entity['screen_name']
431
-                );
432
-            } else if ($entityType == 'media') {
433
-                $replace = sprintf(
434
-                    "<img src=\"%s:%s\" alt=\"%s\" height=\"%s\" width=\"%s\" />",
435
-                    $entity['media_url'],
436
-                    'large',
437
-                    $entity['display_url'],
438
-                    $entity['sizes']['large']['h'],
439
-                    $entity['sizes']['large']['w']
440
-                );
441
-            } else {
442
-                continue 2;
443
-            }
444
-
445
-            $entityHolder[$entity['indices'][0]] = [
446
-                'start' => $entity['indices'][0],
447
-                'end' => $entity['indices'][1],
448
-                'replace' => $replace,
449
-            ];
450
-        }
451
-    }
452
-
453
-    $messageLong = $twitterData['text'];
454
-    krsort($entityHolder);
455
-    foreach($entityHolder as $entity)
456
-    {
457
-        $messageLong =
458
-            mb_substr($messageLong, 0, $entity['start']) .
459
-            $entity['replace'] .
460
-            mb_substr($messageLong, $entity['end'], null, 'UTF-8');
461
-    }
462
-    $messageLong = mb_convert_encoding($messageLong, 'HTML-ENTITIES', 'UTF-8');
463
-    $messageLong = nl2br($messageLong, true);
464
-    $messageLong = "<p>{$messageLong}</p>";
465
-
466
-    $metadata = [];
467
-    if ($twitterData['favorite_count'] > 0) {
468
-        $metadata['favorites'] = $twitterData['favorite_count'];
469
-    }
470
-    if ($twitterData['retweet_count'] > 0) {
471
-        $metadata['retweets'] = $twitterData['retweet_count'];
472
-    }
473
-
474
-    $activityRepository->insertActivity(
475
-        $message,
476
-        $messageLong,
477
-        (new DateTime($twitter['datetime'])),
478
-        $metadata,
479
-        'twitter',
480
-        $twitter['id']
481
-    );
359
+	$twitterData = json_decode($twitter['metadata'], true);
360
+
361
+	$uniqueTwitterCheck = $activityRepository->getActivityByTypeId('twitter', $twitter['id']);
362
+	if ($uniqueTwitterCheck !== false) {
363
+		$metadata = [];
364
+		if ($twitterData['favorite_count'] > 0) {
365
+			$metadata['favorites'] = $twitterData['favorite_count'];
366
+		}
367
+		if ($twitterData['retweet_count'] > 0) {
368
+			$metadata['retweets'] = $twitterData['retweet_count'];
369
+		}
370
+
371
+		$activityRepository->updateActivityMetadata($twitter['id'], $metadata);
372
+		continue;
373
+	}
374
+
375
+	if (
376
+		($twitterData['in_reply_to_user_id'] != null || substr($twitterData['text'], 0, 1) === '@') &&
377
+		$twitterData['favorite_count'] == 0 &&
378
+		$twitterData['retweet_count'] == 0
379
+	) {
380
+		continue;
381
+	}
382
+
383
+	$entityHolder = [];
384
+	foreach ($twitterData['entities'] as $entityType => $entities) {
385
+		foreach ($entities as $entity) {
386
+			if ($entityType == 'urls' || $entityType == 'media') {
387
+				$entityHolder[$entity['indices'][0]] = [
388
+					'start' => $entity['indices'][0],
389
+					'end' => $entity['indices'][1],
390
+					'replace' => "[{$entity['display_url']}]"
391
+				];
392
+			}
393
+		}
394
+	}
395
+
396
+	$message = $twitterData['text'];
397
+	krsort($entityHolder);
398
+	foreach($entityHolder as $entity)
399
+	{
400
+		$message =
401
+			mb_substr($message, 0, $entity['start']) .
402
+			$entity['replace'] .
403
+			mb_substr($message, $entity['end'], null, 'UTF-8');
404
+	}
405
+	$message = mb_convert_encoding($message, 'HTML-ENTITIES', 'UTF-8');
406
+	$message = trim(preg_replace('/\s+/', ' ', $message));
407
+	$message = "Tweeted | {$message}";
408
+
409
+	$entityHolder = [];
410
+	foreach ($twitterData['entities'] as $entityType => $entities) {
411
+		foreach ($entities as $entity) {
412
+			if ($entityType == 'hashtags') {
413
+				$replace = sprintf(
414
+					'<a href="https://twitter.com/search?q=%%23%s&src=hash" rel="nofollow" target="_blank">#%s</a>',
415
+					$entity['text'],
416
+					$entity['text']
417
+				);
418
+			} else if ($entityType == 'urls') {
419
+				$replace = sprintf(
420
+					'<a href="%s" rel="nofollow" target="_blank" title="%s">%s</a>',
421
+					$entity['url'],
422
+					$entity['expanded_url'],
423
+					$entity['display_url']
424
+				);
425
+			} else if ($entityType == 'user_mentions') {
426
+				$replace = sprintf(
427
+					'<a href="https://twitter.com/%s" rel="nofollow" target="_blank" title="Twitter | %s">@%s</a>',
428
+					strtolower($entity['screen_name']),
429
+					$entity['name'],
430
+					$entity['screen_name']
431
+				);
432
+			} else if ($entityType == 'media') {
433
+				$replace = sprintf(
434
+					"<img src=\"%s:%s\" alt=\"%s\" height=\"%s\" width=\"%s\" />",
435
+					$entity['media_url'],
436
+					'large',
437
+					$entity['display_url'],
438
+					$entity['sizes']['large']['h'],
439
+					$entity['sizes']['large']['w']
440
+				);
441
+			} else {
442
+				continue 2;
443
+			}
444
+
445
+			$entityHolder[$entity['indices'][0]] = [
446
+				'start' => $entity['indices'][0],
447
+				'end' => $entity['indices'][1],
448
+				'replace' => $replace,
449
+			];
450
+		}
451
+	}
452
+
453
+	$messageLong = $twitterData['text'];
454
+	krsort($entityHolder);
455
+	foreach($entityHolder as $entity)
456
+	{
457
+		$messageLong =
458
+			mb_substr($messageLong, 0, $entity['start']) .
459
+			$entity['replace'] .
460
+			mb_substr($messageLong, $entity['end'], null, 'UTF-8');
461
+	}
462
+	$messageLong = mb_convert_encoding($messageLong, 'HTML-ENTITIES', 'UTF-8');
463
+	$messageLong = nl2br($messageLong, true);
464
+	$messageLong = "<p>{$messageLong}</p>";
465
+
466
+	$metadata = [];
467
+	if ($twitterData['favorite_count'] > 0) {
468
+		$metadata['favorites'] = $twitterData['favorite_count'];
469
+	}
470
+	if ($twitterData['retweet_count'] > 0) {
471
+		$metadata['retweets'] = $twitterData['retweet_count'];
472
+	}
473
+
474
+	$activityRepository->insertActivity(
475
+		$message,
476
+		$messageLong,
477
+		(new DateTime($twitter['datetime'])),
478
+		$metadata,
479
+		'twitter',
480
+		$twitter['id']
481
+	);
482 482
 }
483 483
 
484 484
 // youtube
@@ -487,39 +487,39 @@  discard block
 block discarded – undo
487 487
 
488 488
 $lastYouTubeActivity = $activityRepository->getActivityLastUpdateByType('youtube');
489 489
 if ($lastYouTubeActivity === false) {
490
-    $lastYouTubeActivityDateTime = new DateTime('2010-08-28');
490
+	$lastYouTubeActivityDateTime = new DateTime('2010-08-28');
491 491
 } else {
492
-    $lastYouTubeActivityDateTime = new DateTime($lastYouTubeActivity['updated_at']);
493
-    $lastYouTubeActivityDateTime->modify('-5 days');
492
+	$lastYouTubeActivityDateTime = new DateTime($lastYouTubeActivity['updated_at']);
493
+	$lastYouTubeActivityDateTime->modify('-5 days');
494 494
 }
495 495
 $newYouTubeActivity = $youTubeRepository->getYouTubesUpdatedSince($lastYouTubeActivityDateTime);
496 496
 foreach ($newYouTubeActivity as $youTube) {
497
-    $uniqueYouTubeCheck = $activityRepository->getActivityByTypeId('youtube', $youTube['id']);
498
-    if ($uniqueYouTubeCheck !== false) {
499
-        continue;
500
-    }
501
-
502
-    $youTubeData = json_decode($youTube['metadata'], true);
503
-
504
-    $message = sprintf(
505
-        'Favorited %s on YouTube.',
506
-        $youTubeData['snippet']['title']
507
-    );
508
-    $messageLong = sprintf(
509
-        "<iframe src=\"%s\" frameborder=\"0\" allowfullscreen></iframe>\n" .
510
-        "<p>Favorited <a href=\"%s\" target=\"_blank\" title=\"YouTube | %s\">%s</a> on YouTube.</p>",
511
-        "https://www.youtube.com/embed/{$youTubeData['contentDetails']['videoId']}",
512
-        "https://youtu.be/{$youTubeData['contentDetails']['videoId']}",
513
-        $youTubeData['snippet']['title'],
514
-        $youTubeData['snippet']['title']
515
-    );
516
-
517
-    $activityRepository->insertActivity(
518
-        $message,
519
-        $messageLong,
520
-        (new DateTime($youTube['datetime'])),
521
-        [],
522
-        'youtube',
523
-        $youTube['id']
524
-    );
497
+	$uniqueYouTubeCheck = $activityRepository->getActivityByTypeId('youtube', $youTube['id']);
498
+	if ($uniqueYouTubeCheck !== false) {
499
+		continue;
500
+	}
501
+
502
+	$youTubeData = json_decode($youTube['metadata'], true);
503
+
504
+	$message = sprintf(
505
+		'Favorited %s on YouTube.',
506
+		$youTubeData['snippet']['title']
507
+	);
508
+	$messageLong = sprintf(
509
+		"<iframe src=\"%s\" frameborder=\"0\" allowfullscreen></iframe>\n" .
510
+		"<p>Favorited <a href=\"%s\" target=\"_blank\" title=\"YouTube | %s\">%s</a> on YouTube.</p>",
511
+		"https://www.youtube.com/embed/{$youTubeData['contentDetails']['videoId']}",
512
+		"https://youtu.be/{$youTubeData['contentDetails']['videoId']}",
513
+		$youTubeData['snippet']['title'],
514
+		$youTubeData['snippet']['title']
515
+	);
516
+
517
+	$activityRepository->insertActivity(
518
+		$message,
519
+		$messageLong,
520
+		(new DateTime($youTube['datetime'])),
521
+		[],
522
+		'youtube',
523
+		$youTube['id']
524
+	);
525 525
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 
396 396
     $message = $twitterData['text'];
397 397
     krsort($entityHolder);
398
-    foreach($entityHolder as $entity)
398
+    foreach ($entityHolder as $entity)
399 399
     {
400 400
         $message =
401 401
             mb_substr($message, 0, $entity['start']) .
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
 
453 453
     $messageLong = $twitterData['text'];
454 454
     krsort($entityHolder);
455
-    foreach($entityHolder as $entity)
455
+    foreach ($entityHolder as $entity)
456 456
     {
457 457
         $messageLong =
458 458
             mb_substr($messageLong, 0, $entity['start']) .
Please login to merge, or discard this patch.