1 | <?php |
||
17 | class TransientStatsdCollector { |
||
18 | |||
19 | /** |
||
20 | * Update this version number when the serialization format |
||
21 | * changes. |
||
22 | */ |
||
23 | const VERSION = '0.2'; |
||
24 | |||
25 | /** |
||
26 | * Available operations |
||
27 | */ |
||
28 | const STATS_INIT = 'init'; |
||
29 | const STATS_INCR = 'incr'; |
||
30 | const STATS_SET = 'set'; |
||
31 | const STATS_MEDIAN = 'median'; |
||
32 | |||
33 | /** |
||
34 | * Namespace occupied by the BlobStore |
||
35 | */ |
||
36 | const CACHE_NAMESPACE = 'smw:stats:store'; |
||
37 | |||
38 | /** |
||
39 | * @var BlobStore |
||
40 | */ |
||
41 | private $blobStore; |
||
42 | |||
43 | /** |
||
44 | * @var string|integer |
||
45 | */ |
||
46 | private $statsdId; |
||
47 | |||
48 | /** |
||
49 | * @var boolean |
||
50 | */ |
||
51 | private $shouldRecord = true; |
||
52 | |||
53 | /** |
||
54 | * @var array |
||
55 | */ |
||
56 | private $stats = array(); |
||
57 | |||
58 | /** |
||
59 | * Identifies an update fingerprint to compare invoked deferred updates |
||
60 | * against each other and filter those with the same print to avoid recording |
||
61 | * duplicate stats. |
||
62 | * |
||
63 | * @var string |
||
64 | */ |
||
65 | private $fingerprint = null; |
||
66 | |||
67 | /** |
||
68 | * @var array |
||
69 | 184 | */ |
|
70 | 184 | private $operations = array(); |
|
71 | 184 | ||
72 | 184 | /** |
|
73 | * @since 2.5 |
||
74 | * |
||
75 | * @param BlobStore $blobStore |
||
76 | * @param string $statsdId |
||
77 | */ |
||
78 | public function __construct( BlobStore $blobStore, $statsdId ) { |
||
83 | |||
84 | /** |
||
85 | * @since 2.5 |
||
86 | * |
||
87 | * @param boolean $shouldRecord |
||
88 | 3 | */ |
|
89 | public function shouldRecord( $shouldRecord ) { |
||
92 | |||
93 | /** |
||
94 | 3 | * @since 2.5 |
|
95 | 3 | * |
|
96 | * @return array |
||
97 | 3 | */ |
|
98 | 3 | public function getStats() { |
|
117 | |||
118 | /** |
||
119 | 171 | * @since 2.5 |
|
120 | 171 | * |
|
121 | 171 | * @param string|array $key |
|
122 | */ |
||
123 | public function incr( $key ) { |
||
132 | 176 | ||
133 | /** |
||
134 | * @since 2.5 |
||
135 | * |
||
136 | * @param string|array $key |
||
137 | * @param string|integer $default |
||
138 | */ |
||
139 | public function init( $key, $default ) { |
||
143 | 177 | ||
144 | /** |
||
145 | * @since 2.5 |
||
146 | * |
||
147 | * @param string|array $key |
||
148 | * @param string|integer $value |
||
149 | */ |
||
150 | public function set( $key, $value ) { |
||
154 | 40 | ||
155 | /** |
||
156 | 7 | * @since 2.5 |
|
157 | * |
||
158 | * @param string|array $key |
||
159 | 40 | * @param integer $value |
|
160 | 40 | */ |
|
161 | public function calcMedian( $key, $value ) { |
||
171 | |||
172 | 4 | /** |
|
173 | * @since 2.5 |
||
174 | 4 | */ |
|
175 | public function saveStats() { |
||
209 | |||
210 | /** |
||
211 | 2 | * @since 2.5 |
|
212 | */ |
||
213 | public function recordStats() { |
||
236 | |||
237 | // http://stackoverflow.com/questions/10123604/multstatsdIdimensional-array-from-string |
||
238 | private function stringToArray( $path, $value ) { |
||
256 | |||
257 | } |
||
258 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.