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

DogStatsDMetricService::increment()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 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