Completed
Branch master (54277f)
by
unknown
24:54
created

NullStatsdDataFactory::produceStatsdData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 1
eloc 9
nc 1
nop 3
1
<?php
2
3
use Liuggio\StatsdClient\Entity\StatsdData;
4
use Liuggio\StatsdClient\Entity\StatsdDataInterface;
5
use Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface;
6
7
/**
8
 * @author Addshore
9
 * @since 1.27
10
 */
11
class NullStatsdDataFactory implements StatsdDataFactoryInterface {
12
13
	/**
14
	 * This function creates a 'timing' StatsdData.
15
	 *
16
	 * @param string|array $key The metric(s) to set.
17
	 * @param float $time The elapsed time (ms) to log
18
	 **/
19
	public function timing( $key, $time ) {
20
	}
21
22
	/**
23
	 * This function creates a 'gauge' StatsdData.
24
	 *
25
	 * @param string|array $key The metric(s) to set.
26
	 * @param float $value The value for the stats.
27
	 **/
28
	public function gauge( $key, $value ) {
29
	}
30
31
	/**
32
	 * This function creates a 'set' StatsdData object
33
	 * A "Set" is a count of unique events.
34
	 * This data type acts like a counter, but supports counting
35
	 * of unique occurrences of values between flushes. The backend
36
	 * receives the number of unique events that happened since
37
	 * the last flush.
38
	 *
39
	 * The reference use case involved tracking the number of active
40
	 * and logged in users by sending the current userId of a user
41
	 * with each request with a key of "uniques" (or similar).
42
	 *
43
	 * @param  string|array $key The metric(s) to set.
44
	 * @param  float $value The value for the stats.
45
	 *
46
	 * @return array
47
	 **/
48
	public function set( $key, $value ) {
49
		return [];
50
	}
51
52
	/**
53
	 * This function creates a 'increment' StatsdData object.
54
	 *
55
	 * @param string|array $key The metric(s) to increment.
56
	 * @param float|1      $sampleRate The rate (0-1) for sampling.
0 ignored issues
show
Documentation introduced by
The doc-type float|1 could not be parsed: Unknown type name "1" at position 6. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
Bug introduced by
There is no parameter named $sampleRate. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
57
	 *
58
	 * @return array
59
	 **/
60
	public function increment( $key ) {
61
		return [];
62
	}
63
64
	/**
65
	 * This function creates a 'decrement' StatsdData object.
66
	 *
67
	 *
68
	 * @param string|array $key The metric(s) to decrement.
69
	 * @param float|1      $sampleRate The rate (0-1) for sampling.
0 ignored issues
show
Documentation introduced by
The doc-type float|1 could not be parsed: Unknown type name "1" at position 6. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
Bug introduced by
There is no parameter named $sampleRate. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
70
	 *
71
	 * @return mixed
72
	 **/
73
	public function decrement( $key ) {
74
		return [];
75
	}
76
77
	/**
78
	 * This function creates a 'updateCount' StatsdData object.
79
	 *
80
	 * @param string|array $key The metric(s) to decrement.
81
	 * @param integer $delta The delta to add to the each metric
82
	 *
83
	 * @return mixed
84
	 **/
85
	public function updateCount( $key, $delta ) {
86
		return [];
87
	}
88
89
	/**
90
	 * Produce a StatsdDataInterface Object.
91
	 *
92
	 * @param string $key The key of the metric
93
	 * @param int $value The amount to increment/decrement each metric by.
94
	 * @param string $metric The metric type
95
	 *                      ("c" for count, "ms" for timing, "g" for gauge, "s" for set)
96
	 *
97
	 * @return StatsdDataInterface
98
	 **/
99
	public function produceStatsdData(
100
		$key,
101
		$value = 1,
102
		$metric = StatsdDataInterface::STATSD_METRIC_COUNT
103
	) {
104
		$data = new StatsdData();
105
		$data->setKey( $key );
106
		$data->setValue( $value );
107
		$data->setMetric( $metric );
108
		return $data;
109
	}
110
111
}
112