Completed
Push — master ( 395ece...4cc44f )
by Ashley
02:58
created
src/WP_Queue/Connections/RedisConnection.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	 *
16 16
 	 * @return bool|int
17 17
 	 */
18
-	public function push( Job $job, $delay = 0 ) {
18
+	public function push(Job $job, $delay = 0) {
19 19
 		//
20 20
 	}
21 21
 
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	 *
34 34
 	 * @param Job $job
35 35
 	 */
36
-	public function delete( $job ) {
36
+	public function delete($job) {
37 37
 		//
38 38
 	}
39 39
 
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	 *
43 43
 	 * @param Job $job
44 44
 	 */
45
-	public function release( $job ) {
45
+	public function release($job) {
46 46
 		//
47 47
 	}
48 48
 
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 * @param Job       $job
53 53
 	 * @param Exception $exception
54 54
 	 */
55
-	public function failure( $job, Exception $exception ) {
55
+	public function failure($job, Exception $exception) {
56 56
 		//
57 57
 	}
58 58
 
Please login to merge, or discard this patch.
src/WP_Queue/Connections/ConnectionInterface.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	 *
16 16
 	 * @return bool|int
17 17
 	 */
18
-	public function push( Job $job, $delay = 0 );
18
+	public function push(Job $job, $delay = 0);
19 19
 
20 20
 	/**
21 21
 	 * Retrieve a job from the queue.
@@ -29,14 +29,14 @@  discard block
 block discarded – undo
29 29
 	 *
30 30
 	 * @param Job $job
31 31
 	 */
32
-	public function delete( $job );
32
+	public function delete($job);
33 33
 
34 34
 	/**
35 35
 	 * Release a job back onto the queue.
36 36
 	 *
37 37
 	 * @param Job $job
38 38
 	 */
39
-	public function release( $job );
39
+	public function release($job);
40 40
 
41 41
 	/**
42 42
 	 * Push a job onto the failure queue.
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 *
47 47
 	 * @return
48 48
 	 */
49
-	public function failure( $job, Exception $exception );
49
+	public function failure($job, Exception $exception);
50 50
 
51 51
 	/**
52 52
 	 * Get total jobs in the queue.
Please login to merge, or discard this patch.
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/Queue.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param ConnectionInterface $connection
23 23
 	 */
24
-	public function __construct( ConnectionInterface $connection ) {
24
+	public function __construct(ConnectionInterface $connection) {
25 25
 		$this->connection = $connection;
26 26
 	}
27 27
 
@@ -33,8 +33,8 @@  discard block
 block discarded – undo
33 33
 	 *
34 34
 	 * @return bool|int
35 35
 	 */
36
-	public function push( Job $job, $delay = 0 ) {
37
-		return $this->connection->push( $job, $delay );
36
+	public function push(Job $job, $delay = 0) {
37
+		return $this->connection->push($job, $delay);
38 38
 	}
39 39
 
40 40
 	/**
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
 	 *
46 46
 	 * @return Cron
47 47
 	 */
48
-	public function cron( $attempts = 3, $interval = 5 ) {
49
-		if ( is_null( $this->cron ) ) {
50
-			$this->cron	= new Cron( get_class( $this->connection ), $this->worker( $attempts ), $interval );
48
+	public function cron($attempts = 3, $interval = 5) {
49
+		if (is_null($this->cron)) {
50
+			$this->cron = new Cron(get_class($this->connection), $this->worker($attempts), $interval);
51 51
 			$this->cron->init();
52 52
 		}
53 53
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	 *
62 62
 	 * @return Worker
63 63
 	 */
64
-	public function worker( $attempts ) {
65
-		return new Worker( $this->connection, $attempts );
64
+	public function worker($attempts) {
65
+		return new Worker($this->connection, $attempts);
66 66
 	}
67 67
 }
68 68
\ No newline at end of file
Please login to merge, or discard this patch.
src/WP_Queue/Cron.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -33,8 +33,8 @@  discard block
 block discarded – undo
33 33
 	 * @param Worker $worker
34 34
 	 * @param int    $interval
35 35
 	 */
36
-	public function __construct( $id, $worker, $interval ) {
37
-		$this->id       = strtolower( str_replace( '\\', '_', $id ) );
36
+	public function __construct($id, $worker, $interval) {
37
+		$this->id       = strtolower(str_replace('\\', '_', $id));
38 38
 		$this->worker   = $worker;
39 39
 		$this->interval = $interval;
40 40
 	}
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	 * @return bool
46 46
 	 */
47 47
 	protected function is_enabled() {
48
-		if ( defined( 'DISABLE_WP_QUEUE_CRON' ) && DISABLE_WP_QUEUE_CRON ) {
48
+		if (defined('DISABLE_WP_QUEUE_CRON') && DISABLE_WP_QUEUE_CRON) {
49 49
 			return false;
50 50
 		}
51 51
 
@@ -58,16 +58,16 @@  discard block
 block discarded – undo
58 58
 	 * @return bool
59 59
 	 */
60 60
 	public function init() {
61
-		if ( ! $this->is_enabled() ) {
61
+		if ( ! $this->is_enabled()) {
62 62
 			return false;
63 63
 		}
64 64
 
65
-		add_filter( 'cron_schedules', array( $this, 'schedule_cron' ) );
66
-		add_action( $this->id, array( $this, 'cron_worker' ) );
65
+		add_filter('cron_schedules', array($this, 'schedule_cron'));
66
+		add_action($this->id, array($this, 'cron_worker'));
67 67
 
68
-		if ( ! wp_next_scheduled( $this->id ) ) {
68
+		if ( ! wp_next_scheduled($this->id)) {
69 69
 			// Schedule health check
70
-			wp_schedule_event( time(), $this->id, $this->id );
70
+			wp_schedule_event(time(), $this->id, $this->id);
71 71
 		}
72 72
 
73 73
 		return true;
@@ -80,10 +80,10 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @return array
82 82
 	 */
83
-	public function schedule_cron( $schedules ) {
84
-		$schedules[ $this->id ] = array(
83
+	public function schedule_cron($schedules) {
84
+		$schedules[$this->id] = array(
85 85
 			'interval' => MINUTE_IN_SECONDS * $this->interval,
86
-			'display'  => sprintf( __( 'Every %d Minutes' ), $this->interval ),
86
+			'display'  => sprintf(__('Every %d Minutes'), $this->interval),
87 87
 		);
88 88
 
89 89
 		return $schedules;
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 * Process any jobs in the queue.
94 94
 	 */
95 95
 	public function cron_worker() {
96
-		if ( $this->is_worker_locked() ) {
96
+		if ($this->is_worker_locked()) {
97 97
 			return;
98 98
 		}
99 99
 
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 
102 102
 		$this->lock_worker();
103 103
 
104
-		while ( ! $this->time_exceeded() && ! $this->memory_exceeded() ) {
105
-			if ( ! $this->worker->process() ) {
104
+		while ( ! $this->time_exceeded() && ! $this->memory_exceeded()) {
105
+			if ( ! $this->worker->process()) {
106 106
 				break;
107 107
 			}
108 108
 		}
@@ -116,21 +116,21 @@  discard block
 block discarded – undo
116 116
 	 * @return bool
117 117
 	 */
118 118
 	protected function is_worker_locked() {
119
-		return (bool) get_site_transient( $this->id );
119
+		return (bool) get_site_transient($this->id);
120 120
 	}
121 121
 
122 122
 	/**
123 123
 	 * Lock the cron worker.
124 124
 	 */
125 125
 	protected function lock_worker() {
126
-		set_site_transient( $this->id, time(), 300 );
126
+		set_site_transient($this->id, time(), 300);
127 127
 	}
128 128
 
129 129
 	/**
130 130
 	 * Unlock the cron worker.
131 131
 	 */
132 132
 	protected function unlock_worker() {
133
-		delete_site_transient( $this->id );
133
+		delete_site_transient($this->id);
134 134
 	}
135 135
 
136 136
 	/**
@@ -143,14 +143,14 @@  discard block
 block discarded – undo
143 143
 	 */
144 144
 	protected function memory_exceeded() {
145 145
 		$memory_limit   = $this->get_memory_limit() * 0.8; // 80% of max memory
146
-		$current_memory = memory_get_usage( true );
146
+		$current_memory = memory_get_usage(true);
147 147
 		$return         = false;
148 148
 
149
-		if ( $current_memory >= $memory_limit ) {
149
+		if ($current_memory >= $memory_limit) {
150 150
 			$return = true;
151 151
 		}
152 152
 
153
-		return apply_filters( 'wp_queue_cron_memory_exceeded', $return );
153
+		return apply_filters('wp_queue_cron_memory_exceeded', $return);
154 154
 	}
155 155
 
156 156
 	/**
@@ -159,18 +159,18 @@  discard block
 block discarded – undo
159 159
 	 * @return int
160 160
 	 */
161 161
 	protected function get_memory_limit() {
162
-		if ( function_exists( 'ini_get' ) ) {
163
-			$memory_limit = ini_get( 'memory_limit' );
162
+		if (function_exists('ini_get')) {
163
+			$memory_limit = ini_get('memory_limit');
164 164
 		} else {
165 165
 			$memory_limit = '256M';
166 166
 		}
167 167
 
168
-		if ( ! $memory_limit || - 1 == $memory_limit ) {
168
+		if ( ! $memory_limit || - 1 == $memory_limit) {
169 169
 			// Unlimited, set to 1GB
170 170
 			$memory_limit = '1000M';
171 171
 		}
172 172
 
173
-		return intval( $memory_limit ) * 1024 * 1024;
173
+		return intval($memory_limit) * 1024 * 1024;
174 174
 	}
175 175
 
176 176
 	/**
@@ -182,13 +182,13 @@  discard block
 block discarded – undo
182 182
 	 * @return bool
183 183
 	 */
184 184
 	protected function time_exceeded() {
185
-		$finish = $this->start_time + apply_filters( 'wp_queue_cron_time_limit', 20 ); // 20 seconds
185
+		$finish = $this->start_time + apply_filters('wp_queue_cron_time_limit', 20); // 20 seconds
186 186
 		$return = false;
187 187
 
188
-		if ( time() >= $finish ) {
188
+		if (time() >= $finish) {
189 189
 			$return = true;
190 190
 		}
191 191
 
192
-		return apply_filters( 'wp_queue_cron_time_exceeded', $return );
192
+		return apply_filters('wp_queue_cron_time_exceeded', $return);
193 193
 	}
194 194
 }
195 195
\ No newline at end of file
Please login to merge, or discard this patch.
src/WP_Queue/Worker.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 * @param ConnectionInterface $connection
25 25
 	 * @param int                 $attempts
26 26
 	 */
27
-	public function __construct( $connection, $attempts = 3 ) {
27
+	public function __construct($connection, $attempts = 3) {
28 28
 		$this->connection = $connection;
29 29
 		$this->attempts   = $attempts;
30 30
 	}
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	public function process() {
38 38
 		$job = $this->connection->pop();
39 39
 
40
-		if ( ! $job ) {
40
+		if ( ! $job) {
41 41
 			return false;
42 42
 		}
43 43
 
@@ -45,24 +45,24 @@  discard block
 block discarded – undo
45 45
 
46 46
 		try {
47 47
 			$job->handle();
48
-		} catch ( Exception $exception ) {
48
+		} catch (Exception $exception) {
49 49
 			$job->release();
50 50
 		}
51 51
 
52
-		if ( $job->attempts() >= $this->attempts ) {
53
-			if ( empty( $exception ) ) {
52
+		if ($job->attempts() >= $this->attempts) {
53
+			if (empty($exception)) {
54 54
 				$exception = new WorkerAttemptsExceededException();
55 55
 			}
56 56
 			
57 57
 			$job->fail();
58 58
 		}
59 59
 
60
-		if ( $job->failed() ) {
61
-			$this->connection->failure( $job, $exception );
62
-		} else if ( $job->released() ) {
63
-			$this->connection->release( $job );
60
+		if ($job->failed()) {
61
+			$this->connection->failure($job, $exception);
62
+		} else if ($job->released()) {
63
+			$this->connection->release($job);
64 64
 		} else {
65
-			$this->connection->delete( $job );
65
+			$this->connection->delete($job);
66 66
 		}
67 67
 
68 68
 		return true;
Please login to merge, or discard this patch.
src/WP_Queue/Connections/DatabaseConnection.php 1 patch
Spacing   +47 added lines, -47 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,14 +242,14 @@  discard block
 block discarded – undo
242 242
 	 *
243 243
 	 * @return string
244 244
 	 */
245
-	protected function format_exception( Exception $exception ) {
246
-		$string = get_class( $exception );
245
+	protected function format_exception(Exception $exception) {
246
+		$string = get_class($exception);
247 247
 
248
-		if ( ! empty( $exception->getMessage() ) ) {
248
+		if ( ! empty($exception->getMessage())) {
249 249
 			$string .= " : {$exception->getMessage()}";
250 250
 		}
251 251
 
252
-		if ( ! empty( $exception->getCode() ) ) {
252
+		if ( ! empty($exception->getCode())) {
253 253
 			$string .= " (#{$exception->getCode()})";
254 254
 		}
255 255
 
Please login to merge, or discard this patch.
src/WP_Queue/QueueManager.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -21,12 +21,12 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @return Queue
23 23
 	 */
24
-	public static function resolve( $connection ) {
25
-		if ( isset( static::$instances[ $connection ] ) ) {
26
-			return static::$instances[ $connection ];
24
+	public static function resolve($connection) {
25
+		if (isset(static::$instances[$connection])) {
26
+			return static::$instances[$connection];
27 27
 		}
28 28
 
29
-		return static::build( $connection );
29
+		return static::build($connection);
30 30
 	}
31 31
 
32 32
 	/**
@@ -37,16 +37,16 @@  discard block
 block discarded – undo
37 37
 	 * @return Queue
38 38
 	 * @throws \Exception
39 39
 	 */
40
-	protected static function build( $connection ) {
40
+	protected static function build($connection) {
41 41
 		$connections = static::connections();
42 42
 
43
-		if ( empty( $connections[ $connection ] ) ) {
43
+		if (empty($connections[$connection])) {
44 44
 			throw new ConnectionNotFoundException();
45 45
 		}
46 46
 
47
-		static::$instances[ $connection ] = new Queue( $connections[ $connection ] );
47
+		static::$instances[$connection] = new Queue($connections[$connection]);
48 48
 
49
-		return static::$instances[ $connection ];
49
+		return static::$instances[$connection];
50 50
 	}
51 51
 
52 52
 	/**
@@ -56,11 +56,11 @@  discard block
 block discarded – undo
56 56
 	 */
57 57
 	protected static function connections() {
58 58
 		$connections = array(
59
-			'database' => new DatabaseConnection( $GLOBALS['wpdb'] ),
59
+			'database' => new DatabaseConnection($GLOBALS['wpdb']),
60 60
 			'redis'    => new RedisConnection(),
61 61
 			'sync'     => new SyncConnection(),
62 62
 		);
63 63
 
64
-		return apply_filters( 'wp_queue_connections', $connections );
64
+		return apply_filters('wp_queue_connections', $connections);
65 65
 	}
66 66
 }
67 67
\ No newline at end of file
Please login to merge, or discard this patch.
src/functions.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 use WP_Queue\Queue;
4 4
 use WP_Queue\QueueManager;
5 5
 
6
-if ( ! function_exists( 'wp_queue' ) ) {
6
+if ( ! function_exists('wp_queue')) {
7 7
 	/**
8 8
 	 * Return Queue instance.
9 9
 	 *
@@ -11,23 +11,23 @@  discard block
 block discarded – undo
11 11
 	 *
12 12
 	 * @return Queue
13 13
 	 */
14
-	function wp_queue( $connection = '' ) {
15
-		if( empty( $connection ) ) {
16
-			$connection = apply_filters( 'wp_queue_default_connection', 'database' );
14
+	function wp_queue($connection = '') {
15
+		if (empty($connection)) {
16
+			$connection = apply_filters('wp_queue_default_connection', 'database');
17 17
 		}
18 18
 		
19
-		return QueueManager::resolve( $connection );
19
+		return QueueManager::resolve($connection);
20 20
 	}
21 21
 }
22 22
 
23
-if ( ! function_exists( 'wp_queue_install_tables' ) ) {
23
+if ( ! function_exists('wp_queue_install_tables')) {
24 24
 	/**
25 25
 	 * Install database tables
26 26
 	 */
27 27
 	function wp_queue_install_tables() {
28 28
 		global $wpdb;
29 29
 
30
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
30
+		require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
31 31
 
32 32
 		$wpdb->hide_errors();
33 33
 		$charset_collate = $wpdb->get_charset_collate();
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 				PRIMARY KEY  (id)
43 43
 				) $charset_collate;";
44 44
 
45
-		dbDelta( $sql );
45
+		dbDelta($sql);
46 46
 
47 47
 		$sql = "CREATE TABLE {$wpdb->prefix}queue_failures (
48 48
 				id bigint(20) NOT NULL AUTO_INCREMENT,
@@ -52,6 +52,6 @@  discard block
 block discarded – undo
52 52
 				PRIMARY KEY  (id)
53 53
 				) $charset_collate;";
54 54
 
55
-		dbDelta( $sql );
55
+		dbDelta($sql);
56 56
 	}
57 57
 }
58 58
\ No newline at end of file
Please login to merge, or discard this patch.