Skip to content

Commit

Permalink
Allow strings as value for MessageEntity objects.
Browse files Browse the repository at this point in the history
  • Loading branch information
mihai-amihailesei committed Sep 18, 2023
1 parent 0796007 commit 1d91b15
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/M6Web/Component/Statsd/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function getServerKey($stats)
protected function addToSend($stats, $value, $sampleRate, $unit, $tags)
{
$message = new MessageEntity(
(string) $stats, (int) $value, (string) $unit, (float) $sampleRate, $tags
(string) $stats, $value, (string) $unit, (float) $sampleRate, $tags
);

$queue = [
Expand Down
12 changes: 6 additions & 6 deletions src/M6Web/Component/Statsd/MessageEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ class MessageEntity
protected $tags = [];

/**
* @param string $node node
* @param int $value value of the node
* @param string $unit units (ms for timer, c for counting ...)
* @param float $sampleRate sampling rate
* @param array $tags Tags key => value for influxDb
* @param string $node node
* @param int|string $value value of the node
* @param string $unit units (ms for timer, c for counting ...)
* @param float $sampleRate sampling rate
* @param array $tags Tags key => value for influxDb
*
* @return MessageEntity
*/
Expand Down Expand Up @@ -60,7 +60,7 @@ protected function checkConstructor()
throw new Exception('node and unit have to be a string');
}

if (!is_int($this->value)) {
if (!is_int(intval($this->value))) {
throw new Exception('value has to be an integer');
}

Expand Down

0 comments on commit 1d91b15

Please sign in to comment.