Completed
Pull Request — master (#27)
by Frederic
04:50 queued 02:40
created

DogStatsDMetricService   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 39
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A increment() 0 5 1
A timing() 0 5 1
1
<?php
2
3
namespace Burrow\Metric;
4
5
use Beberlei\Metrics\Collector\DogStatsD as Collector;
6
7
class DogStatsDMetricService implements MetricService
8
{
9
    /** @var Collector */
10
    private $collector;
11
12
    /** @var array */
13
    private $tags;
14
15
    /**
16
     * MetricService constructor.
17
     *
18
     * @param Collector $collector
19
     * @param array     $tags
20
     */
21 9
    public function __construct(Collector $collector, array $tags = [])
22
    {
23 9
        $this->collector = $collector;
24 9
        $this->tags = $tags;
25 9
    }
26
27
    /**
28
     * @param $key
29
     */
30 3
    public function increment($key)
31
    {
32 3
        $this->collector->increment($key, $this->tags);
33 3
        $this->collector->flush();
34 3
    }
35
36
    /**
37
     * @param $key
38
     * @param float $timeInMs
39
     */
40 3
    public function timing($key, $timeInMs)
41
    {
42 3
        $this->collector->timing($key, $timeInMs, $this->tags);
43 3
        $this->collector->flush();
44 3
    }
45
}
46