Test Failed
Pull Request — master (#56)
by
unknown
02:50
created

RedisFailure   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 22
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 1
1
<?php
2
3
namespace Resque\Failure;
4
5
use Resque\Resque;
6
use stdClass;
7
8
/**
9
 * Redis backend for storing failed Resque jobs.
10
 *
11
 * @package		Resque/Failure
12
 * @author		Chris Boulton <[email protected]>
13
 * @license		http://www.opensource.org/licenses/mit-license.php
14
 */
15
16
class RedisFailure implements FailureInterface
17
{
18
	/**
19
	 * Initialize a failed job class and save it (where appropriate).
20
	 *
21
	 * @param object $payload Object containing details of the failed job.
22
	 * @param object $exception Instance of the exception that was thrown by the failed job.
23
	 * @param object $worker Instance of \Resque\Worker\ResqueWorker that received the job.
24
	 * @param string $queue The name of the queue the job was fetched from.
25
	 */
26
	public function __construct($payload, $exception, $worker, $queue)
27
	{
28
		$data = new stdClass();
29
		$data->failed_at = date('c');
30
		$data->payload = $payload;
31
		$data->exception = get_class($exception);
32
		$data->error = $exception->getMessage();
33
		$data->backtrace = explode("\n", $exception->getTraceAsString());
34
		$data->worker = (string)$worker;
35
		$data->queue = $queue;
36
		$data = json_encode($data);
37
		Resque::redis()->rpush('failed', $data);
0 ignored issues
show
Bug introduced by
The method rpush() does not exist on Resque\Redis. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

37
		Resque::redis()->/** @scrutinizer ignore-call */ rpush('failed', $data);
Loading history...
38
	}
39
}
40