@@ -30,7 +30,7 @@ public function updateHistogram(array $data): void
3030 {
3131 // Initialize the sum
3232 $ sumKey = $ this ->histogramBucketValueKey ($ data , 'sum ' );
33- $ new = apcu_add ($ sumKey , $ this ->toInteger (0 ));
33+ $ new = apcu_add ($ sumKey , $ this ->toBinaryRepresentationAsInteger (0 ));
3434
3535 // If sum does not exist, assume a new histogram and store the metadata
3636 if ($ new ) {
@@ -43,7 +43,7 @@ public function updateHistogram(array $data): void
4343 while (!$ done ) {
4444 $ old = apcu_fetch ($ sumKey );
4545 if ($ old !== false ) {
46- $ done = apcu_cas ($ sumKey , $ old , $ this ->toInteger ($ this ->fromInteger ($ old ) + $ data ['value ' ]));
46+ $ done = apcu_cas ($ sumKey , $ old , $ this ->toBinaryRepresentationAsInteger ($ this ->fromBinaryRepresentationAsInteger ($ old ) + $ data ['value ' ]));
4747 }
4848 }
4949
@@ -68,10 +68,10 @@ public function updateGauge(array $data): void
6868 {
6969 $ valueKey = $ this ->valueKey ($ data );
7070 if ($ data ['command ' ] === Adapter::COMMAND_SET ) {
71- apcu_store ($ valueKey , $ this ->toInteger ($ data ['value ' ]));
71+ apcu_store ($ valueKey , $ this ->toBinaryRepresentationAsInteger ($ data ['value ' ]));
7272 apcu_store ($ this ->metaKey ($ data ), json_encode ($ this ->metaData ($ data )));
7373 } else {
74- $ new = apcu_add ($ valueKey , $ this ->toInteger (0 ));
74+ $ new = apcu_add ($ valueKey , $ this ->toBinaryRepresentationAsInteger (0 ));
7575 if ($ new ) {
7676 apcu_store ($ this ->metaKey ($ data ), json_encode ($ this ->metaData ($ data )));
7777 }
@@ -80,7 +80,7 @@ public function updateGauge(array $data): void
8080 while (!$ done ) {
8181 $ old = apcu_fetch ($ valueKey );
8282 if ($ old !== false ) {
83- $ done = apcu_cas ($ valueKey , $ old , $ this ->toInteger ($ this ->fromInteger ($ old ) + $ data ['value ' ]));
83+ $ done = apcu_cas ($ valueKey , $ old , $ this ->toBinaryRepresentationAsInteger ($ this ->fromBinaryRepresentationAsInteger ($ old ) + $ data ['value ' ]));
8484 }
8585 }
8686 }
@@ -103,7 +103,7 @@ public function updateCounter(array $data): void
103103 while (!$ done ) {
104104 $ old = apcu_fetch ($ valueKey );
105105 if ($ old !== false ) {
106- $ done = apcu_cas ($ valueKey , $ old , $ this ->toInteger ($ this ->fromInteger ($ old ) + $ data ['value ' ]));
106+ $ done = apcu_cas ($ valueKey , $ old , $ this ->toBinaryRepresentationAsInteger ($ this ->fromBinaryRepresentationAsInteger ($ old ) + $ data ['value ' ]));
107107 }
108108 }
109109 }
@@ -190,7 +190,7 @@ private function collectCounters(): array
190190 'name ' => $ metaData ['name ' ],
191191 'labelNames ' => [],
192192 'labelValues ' => $ this ->decodeLabelValues ($ labelValues ),
193- 'value ' => $ this ->fromInteger ($ value ['value ' ]),
193+ 'value ' => $ this ->fromBinaryRepresentationAsInteger ($ value ['value ' ]),
194194 ];
195195 }
196196 $ this ->sortSamples ($ data ['samples ' ]);
@@ -221,7 +221,7 @@ private function collectGauges(): array
221221 'name ' => $ metaData ['name ' ],
222222 'labelNames ' => [],
223223 'labelValues ' => $ this ->decodeLabelValues ($ labelValues ),
224- 'value ' => $ this ->fromInteger ($ value ['value ' ]),
224+ 'value ' => $ this ->fromBinaryRepresentationAsInteger ($ value ['value ' ]),
225225 ];
226226 }
227227
@@ -298,7 +298,7 @@ private function collectHistograms(): array
298298 'name ' => $ metaData ['name ' ] . '_sum ' ,
299299 'labelNames ' => [],
300300 'labelValues ' => $ decodedLabelValues ,
301- 'value ' => $ this ->fromInteger ($ histogramBuckets [$ labelValues ]['sum ' ]),
301+ 'value ' => $ this ->fromBinaryRepresentationAsInteger ($ histogramBuckets [$ labelValues ]['sum ' ]),
302302 ];
303303 }
304304 $ histograms [] = new MetricFamilySamples ($ data );
@@ -310,7 +310,7 @@ private function collectHistograms(): array
310310 * @param mixed $val
311311 * @return int
312312 */
313- private function toInteger ($ val ): int
313+ private function toBinaryRepresentationAsInteger ($ val ): int
314314 {
315315 return unpack ('Q ' , pack ('d ' , $ val ))[1 ];
316316 }
@@ -319,7 +319,7 @@ private function toInteger($val): int
319319 * @param mixed $val
320320 * @return float
321321 */
322- private function fromInteger ($ val ): float
322+ private function fromBinaryRepresentationAsInteger ($ val ): float
323323 {
324324 return unpack ('d ' , pack ('Q ' , $ val ))[1 ];
325325 }
0 commit comments