Test Failed
Pull Request — master (#56)
by
unknown
04:22 queued 01:59
created

PID::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Resque\Job;
4
5
use Resque\Resque;
6
7
/**
8
 * PID tracker for the forked worker job.
9
 *
10
 * @package		Resque/Job
11
 * @author		Chris Boulton <[email protected]>
12
 * @license		http://www.opensource.org/licenses/mit-license.php
13
 */
14
class PID
15
{
16
	/**
17
	 * Create a new PID tracker item for the supplied job ID.
18
	 *
19
	 * @param string $id The ID of the job to track the PID of.
20
	 */
21
	public static function create($id)
22
	{
23
		Resque::redis()->set('job:' . $id . ':pid', (string)getmypid());
0 ignored issues
show
Bug introduced by
The method set() 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

23
		Resque::redis()->/** @scrutinizer ignore-call */ set('job:' . $id . ':pid', (string)getmypid());
Loading history...
24
	}
25
26
	/**
27
	 * Fetch the PID for the process actually executing the job.
28
	 *
29
	 * @param string $id The ID of the job to get the PID of.
30
	 *
31
	 * @return int PID of the process doing the job (on non-forking OS, PID of the worker, otherwise forked PID).
32
	 */
33
	public static function get($id)
34
	{
35
		return (int)Resque::redis()->get('job:' . $id . ':pid');
0 ignored issues
show
Bug introduced by
The method get() 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

35
		return (int)Resque::redis()->/** @scrutinizer ignore-call */ get('job:' . $id . ':pid');
Loading history...
36
	}
37
38
	/**
39
	 * Remove the PID tracker for the job.
40
	 *
41
	 * @param string $id The ID of the job to remove the tracker from.
42
	 */
43
	public static function del($id)
44
	{
45
		Resque::redis()->del('job:' . $id . ':pid');
0 ignored issues
show
Bug introduced by
The method del() 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

45
		Resque::redis()->/** @scrutinizer ignore-call */ del('job:' . $id . ':pid');
Loading history...
46
	}
47
}
48