Resque_Stat   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 5
c 2
b 1
f 0
dl 0
loc 46
ccs 8
cts 8
cp 1
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A decr() 0 3 1
A get() 0 3 1
A clear() 0 3 1
A incr() 0 3 1
1
<?php
2
3
/**
4
 * Resque statistic management (jobs processed, failed, etc)
5
 *
6
 * @package		Resque/Stat
7
 * @author		Chris Boulton <[email protected]>
8
 * @license		http://www.opensource.org/licenses/mit-license.php
9
 */
10
class Resque_Stat
11
{
12
	/**
13
	 * Get the value of the supplied statistic counter for the specified statistic.
14
	 *
15
	 * @param string $stat The name of the statistic to get the stats for.
16
	 * @return mixed Value of the statistic.
17 8
	 */
18
	public static function get($stat)
19 8
	{
20
		return (int)Resque::redis()->get('stat:' . $stat);
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

20
		return (int)Resque::redis()->/** @scrutinizer ignore-call */ get('stat:' . $stat);
Loading history...
21
	}
22
23
	/**
24
	 * Increment the value of the specified statistic by a certain amount (default is 1)
25
	 *
26
	 * @param string $stat The name of the statistic to increment.
27
	 * @param int $by The amount to increment the statistic by.
28
	 * @return boolean True if successful, false if not.
29 17
	 */
30
	public static function incr($stat, $by = 1)
31 17
	{
32
		return (bool)Resque::redis()->incrby('stat:' . $stat, $by);
0 ignored issues
show
Bug introduced by
The method incrby() 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

32
		return (bool)Resque::redis()->/** @scrutinizer ignore-call */ incrby('stat:' . $stat, $by);
Loading history...
33
	}
34
35
	/**
36
	 * Decrement the value of the specified statistic by a certain amount (default is 1)
37
	 *
38
	 * @param string $stat The name of the statistic to decrement.
39
	 * @param int $by The amount to decrement the statistic by.
40
	 * @return boolean True if successful, false if not.
41 2
	 */
42
	public static function decr($stat, $by = 1)
43 2
	{
44
		return (bool)Resque::redis()->decrby('stat:' . $stat, $by);
0 ignored issues
show
Bug introduced by
The method decrby() 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

44
		return (bool)Resque::redis()->/** @scrutinizer ignore-call */ decrby('stat:' . $stat, $by);
Loading history...
45
	}
46
47
	/**
48
	 * Delete a statistic with the given name.
49
	 *
50
	 * @param string $stat The name of the statistic to delete.
51
	 * @return boolean True if successful, false if not.
52 17
	 */
53
	public static function clear($stat)
54 17
	{
55
		return (bool)Resque::redis()->del('stat:' . $stat);
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

55
		return (bool)Resque::redis()->/** @scrutinizer ignore-call */ del('stat:' . $stat);
Loading history...
56
	}
57
}
58