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

Counter::builder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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