Completed
Push — develop ( 28a887...d46380 )
by Stan
02:57
created

Counter   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 77.78%

Importance

Changes 0
Metric Value
dl 0
loc 34
ccs 7
cts 9
cp 0.7778
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A incrementBy() 0 5 1
A increment() 0 3 1
A type() 0 3 1
A builder() 0 3 1
1
<?php
2
3
namespace Krenor\Prometheus\Metrics;
4
5
use Krenor\Prometheus\Contracts\Metric;
6
use Tightenco\Collect\Support\Collection;
7
use Krenor\Prometheus\Contracts\SamplesBuilder;
8
use Krenor\Prometheus\Contracts\Types\Incrementable;
9
use Krenor\Prometheus\Storage\Builders\CounterSamplesBuilder;
10
11
abstract class Counter extends Metric implements Incrementable
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16 6
    final public function builder(Collection $items): SamplesBuilder
17
    {
18 6
        return new CounterSamplesBuilder($this, $items);
19
    }
20
21
    /**
22
     * {@inheritdoc}
23
     */
24 6
    final public function type(): string
25
    {
26 6
        return 'counter';
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function increment(array $labels): self
33
    {
34
        return $this->incrementBy(1, $labels);
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40 5
    public function incrementBy(float $value, array $labels): self
41
    {
42 5
        static::$storage->increment($this, $value, $labels);
43
44 5
        return $this;
45
    }
46
}
47