Passed
Push — master ( 86f5a9...0398fd )
by Ashley
01:36
created
src/WP_Queue/Job.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	 *
62 62
 	 * @param int $id
63 63
 	 */
64
-	public function set_id( $id ) {
64
+	public function set_id($id) {
65 65
 		$this->id = $id;
66 66
 	}
67 67
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	 *
80 80
 	 * @param int $attempts
81 81
 	 */
82
-	public function set_attempts( $attempts ) {
82
+	public function set_attempts($attempts) {
83 83
 		$this->attempts = $attempts;
84 84
 	}
85 85
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 *
98 98
 	 * @param null|Carbon $reserved_at
99 99
 	 */
100
-	public function set_reserved_at( $reserved_at ) {
100
+	public function set_reserved_at($reserved_at) {
101 101
 		$this->reserved_at = $reserved_at;
102 102
 	}
103 103
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	 *
116 116
 	 * @param Carbon $available_at
117 117
 	 */
118
-	public function set_available_at( Carbon $available_at ) {
118
+	public function set_available_at(Carbon $available_at) {
119 119
 		$this->available_at = $available_at;
120 120
 	}
121 121
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	 *
134 134
 	 * @param Carbon $created_at
135 135
 	 */
136
-	public function set_created_at( Carbon $created_at ) {
136
+	public function set_created_at(Carbon $created_at) {
137 137
 		$this->created_at = $created_at;
138 138
 	}
139 139
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 	 * @return array
177 177
 	 */
178 178
 	public function __sleep() {
179
-		$object_props   = get_object_vars( $this );
179
+		$object_props   = get_object_vars($this);
180 180
 		$excluded_props = array(
181 181
 			'id',
182 182
 			'attempts',
@@ -187,11 +187,11 @@  discard block
 block discarded – undo
187 187
 			'failed',
188 188
 		);
189 189
 
190
-		foreach ( $excluded_props as $prop ) {
191
-			unset( $object_props[ $prop ] );
190
+		foreach ($excluded_props as $prop) {
191
+			unset($object_props[$prop]);
192 192
 		}
193 193
 
194
-		return array_keys( $object_props );
194
+		return array_keys($object_props);
195 195
 	}
196 196
 
197 197
 }
198 198
\ No newline at end of file
Please login to merge, or discard this patch.
src/WP_Queue/Connections/DatabaseConnection.php 1 patch
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 *
29 29
 	 * @param wpdb $wpdb
30 30
 	 */
31
-	public function __construct( $wpdb ) {
31
+	public function __construct($wpdb) {
32 32
 		$this->database       = $wpdb;
33 33
 		$this->jobs_table     = $this->database->prefix . 'queue_jobs';
34 34
 		$this->failures_table = $this->database->prefix . 'queue_failures';
@@ -42,14 +42,14 @@  discard block
 block discarded – undo
42 42
 	 *
43 43
 	 * @return bool|int
44 44
 	 */
45
-	public function push( Job $job, $delay = 0 ) {
46
-		$result = $this->database->insert( $this->jobs_table, array(
47
-			'job'          => serialize( $job ),
48
-			'available_at' => $this->datetime( $delay ),
45
+	public function push(Job $job, $delay = 0) {
46
+		$result = $this->database->insert($this->jobs_table, array(
47
+			'job'          => serialize($job),
48
+			'available_at' => $this->datetime($delay),
49 49
 			'created_at'   => $this->datetime(),
50
-		) );
50
+		));
51 51
 
52
-		if ( ! $result ) {
52
+		if ( ! $result) {
53 53
 			return false;
54 54
 		}
55 55
 
@@ -64,23 +64,23 @@  discard block
 block discarded – undo
64 64
 	public function pop() {
65 65
 		$this->release_reserved();
66 66
 
67
-		$sql = $this->database->prepare( "
67
+		$sql = $this->database->prepare("
68 68
 			SELECT * FROM {$this->jobs_table}
69 69
 			WHERE reserved_at IS NULL
70 70
 			AND available_at <= %s
71 71
 			ORDER BY available_at
72 72
 			LIMIT 1
73
-		", $this->datetime() );
73
+		", $this->datetime());
74 74
 
75
-		$raw_job = $this->database->get_row( $sql );
75
+		$raw_job = $this->database->get_row($sql);
76 76
 
77
-		if ( is_null( $raw_job ) ) {
77
+		if (is_null($raw_job)) {
78 78
 			return false;
79 79
 		}
80 80
 
81
-		$job = $this->vitalize_job( $raw_job );
81
+		$job = $this->vitalize_job($raw_job);
82 82
 
83
-		$this->reserve( $job );
83
+		$this->reserve($job);
84 84
 
85 85
 		return $job;
86 86
 	}
@@ -92,12 +92,12 @@  discard block
 block discarded – undo
92 92
 	 *
93 93
 	 * @return bool
94 94
 	 */
95
-	public function delete( $job ) {
95
+	public function delete($job) {
96 96
 		$where = array(
97 97
 			'id' => $job->id(),
98 98
 		);
99 99
 
100
-		if ( $this->database->delete( $this->jobs_table, $where ) ) {
100
+		if ($this->database->delete($this->jobs_table, $where)) {
101 101
 			return true;
102 102
 		}
103 103
 
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
111 111
 	 *
112 112
 	 * @return bool
113 113
 	 */
114
-	public function release( $job ) {
115
-		$data  = array(
116
-			'job'         => serialize( $job ),
114
+	public function release($job) {
115
+		$data = array(
116
+			'job'         => serialize($job),
117 117
 			'attempts'    => $job->attempts(),
118 118
 			'reserved_at' => null,
119 119
 		);
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 			'id' => $job->id(),
122 122
 		);
123 123
 
124
-		if ( $this->database->update( $this->jobs_table, $data, $where ) ) {
124
+		if ($this->database->update($this->jobs_table, $data, $where)) {
125 125
 			return true;
126 126
 		}
127 127
 
@@ -136,15 +136,15 @@  discard block
 block discarded – undo
136 136
 	 *
137 137
 	 * @return bool
138 138
 	 */
139
-	public function failure( $job, Exception $exception ) {
140
-		$insert = $this->database->insert( $this->failures_table, array(
141
-			'job'       => serialize( $job ),
142
-			'error'     => $this->format_exception( $exception ),
139
+	public function failure($job, Exception $exception) {
140
+		$insert = $this->database->insert($this->failures_table, array(
141
+			'job'       => serialize($job),
142
+			'error'     => $this->format_exception($exception),
143 143
 			'failed_at' => $this->datetime(),
144
-		) );
144
+		));
145 145
 
146
-		if ( $insert ) {
147
-			$this->delete( $job );
146
+		if ($insert) {
147
+			$this->delete($job);
148 148
 
149 149
 			return true;
150 150
 		}
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 	public function jobs() {
161 161
 		$sql = "SELECT COUNT(*) FROM {$this->jobs_table}";
162 162
 		
163
-		return (int) $this->database->get_var( $sql );
163
+		return (int) $this->database->get_var($sql);
164 164
 	}
165 165
 
166 166
 	/**
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 	public function failed_jobs() {
172 172
 		$sql = "SELECT COUNT(*) FROM {$this->failures_table}";
173 173
 
174
-		return (int) $this->database->get_var( $sql );
174
+		return (int) $this->database->get_var($sql);
175 175
 	}
176 176
 
177 177
 	/**
@@ -179,14 +179,14 @@  discard block
 block discarded – undo
179 179
 	 *
180 180
 	 * @param Job $job
181 181
 	 */
182
-	protected function reserve( $job ) {
182
+	protected function reserve($job) {
183 183
 		$data = array(
184 184
 			'reserved_at' => $this->datetime(),
185 185
 		);
186 186
 
187
-		$this->database->update( $this->jobs_table, $data, array(
187
+		$this->database->update($this->jobs_table, $data, array(
188 188
 			'id' => $job->id(),
189
-		) );
189
+		));
190 190
 	}
191 191
 
192 192
 	/**
@@ -195,12 +195,12 @@  discard block
 block discarded – undo
195 195
 	protected function release_reserved() {
196 196
 		$expired = $this->datetime( -300 );
197 197
 
198
-		$sql = $this->database->prepare( "
198
+		$sql = $this->database->prepare("
199 199
 				UPDATE {$this->jobs_table}
200 200
 				SET attempts = attempts + 1, reserved_at = NULL
201
-				WHERE reserved_at <= %s", $expired );
201
+				WHERE reserved_at <= %s", $expired);
202 202
 
203
-		$this->database->query( $sql );
203
+		$this->database->query($sql);
204 204
 	}
205 205
 
206 206
 	/**
@@ -210,14 +210,14 @@  discard block
 block discarded – undo
210 210
 	 *
211 211
 	 * @return Job
212 212
 	 */
213
-	protected function vitalize_job( $raw_job ) {
214
-		$job = unserialize( $raw_job->job );
213
+	protected function vitalize_job($raw_job) {
214
+		$job = unserialize($raw_job->job);
215 215
 
216
-		$job->set_id( $raw_job->id );
217
-		$job->set_attempts( $raw_job->attempts );
218
-		$job->set_reserved_at( empty( $raw_job->reserved_at ) ? null : new Carbon( $raw_job->reserved_at ) );
219
-		$job->set_available_at( new Carbon( $raw_job->available_at ) );
220
-		$job->set_created_at( new Carbon( $raw_job->created_at ) );
216
+		$job->set_id($raw_job->id);
217
+		$job->set_attempts($raw_job->attempts);
218
+		$job->set_reserved_at(empty($raw_job->reserved_at) ? null : new Carbon($raw_job->reserved_at));
219
+		$job->set_available_at(new Carbon($raw_job->available_at));
220
+		$job->set_created_at(new Carbon($raw_job->created_at));
221 221
 
222 222
 		return $job;
223 223
 	}
@@ -229,10 +229,10 @@  discard block
 block discarded – undo
229 229
 	 *
230 230
 	 * @return string
231 231
 	 */
232
-	protected function datetime( $offset = 0 ) {
232
+	protected function datetime($offset = 0) {
233 233
 		$timestamp = time() + $offset;
234 234
 
235
-		return gmdate( 'Y-m-d H:i:s', $timestamp );
235
+		return gmdate('Y-m-d H:i:s', $timestamp);
236 236
 	}
237 237
 
238 238
 	/**
@@ -242,12 +242,12 @@  discard block
 block discarded – undo
242 242
 	 *
243 243
 	 * @return null|string
244 244
 	 */
245
-	protected function format_exception( Exception $exception ) {
246
-		if ( is_null( $exception ) ) {
245
+	protected function format_exception(Exception $exception) {
246
+		if (is_null($exception)) {
247 247
 			return null;
248 248
 		}
249 249
 
250
-		$class = get_class( $exception );
250
+		$class = get_class($exception);
251 251
 
252 252
 		return "{$class}: {$exception->getMessage()} (#{$exception->getCode()})";
253 253
 	}
Please login to merge, or discard this patch.