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

Stat   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 46
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

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

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

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

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

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