23 use Liuggio\StatsdClient\Entity\StatsdData;
24 use Liuggio\StatsdClient\Entity\StatsdDataInterface;
25 use Liuggio\StatsdClient\Factory\StatsdDataFactory;
48 parent::__construct();
64 $key = preg_replace(
'/[:.]+/',
'.', $key );
65 $key = preg_replace(
'/[^a-z0-9.]+/i',
'_', $key );
66 $key = trim( $key,
'_.' );
67 return str_replace( [
'._',
'_.' ],
'.', $key );
71 $key, $value = 1, $metric = StatsdDataInterface::STATSD_METRIC_COUNT
73 $entity = $this->produceStatsdDataEntity();
74 if ( !$this->enabled ) {
77 if ( $key !==
null ) {
79 $entity->setKey( $key );
81 if ( $value !==
null ) {
82 $entity->setValue( $value );
84 if ( $metric !==
null ) {
85 $entity->setMetric( $metric );
88 if ( !( $metric === StatsdDataInterface::STATSD_METRIC_COUNT && !$value ) ) {
89 $this->buffer[] = $entity;
95 return !empty( $this->buffer );
111 return count( $this->buffer );