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

Gauge   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Test Coverage

Coverage 76.47%

Importance

Changes 0
Metric Value
dl 0
loc 62
ccs 13
cts 17
cp 0.7647
rs 10
c 0
b 0
f 0
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A decrementBy() 0 5 1
A incrementBy() 0 5 1
A type() 0 3 1
A set() 0 5 1
A increment() 0 3 1
A decrement() 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\Types\Settable;
8
use Krenor\Prometheus\Contracts\SamplesBuilder;
9
use Krenor\Prometheus\Contracts\Types\Incrementable;
10
use Krenor\Prometheus\Contracts\Types\Decrementable;
11
use Krenor\Prometheus\Storage\Builders\GaugeSamplesBuilder;
12
13
abstract class Gauge extends Metric implements Incrementable, Decrementable, Settable
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18 15
    final public function builder(Collection $items): SamplesBuilder
19
    {
20 15
        return new GaugeSamplesBuilder($this, $items);
21
    }
22
23
    /**
24
     * {@inheritdoc}
25
     */
26 15
    final public function type(): string
27
    {
28 15
        return 'gauge';
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function increment(array $labels): self
35
    {
36
        return $this->incrementBy(1, $labels);
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42 10
    public function incrementBy(float $value, array $labels): self
43
    {
44 10
        static::$storage->increment($this, $value, $labels);
45
46 10
        return $this;
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function decrement(array $labels): self
53
    {
54
        return $this->decrementBy(1, $labels);
55
    }
56
57
    /**
58
     * {@inheritdoc}
59
     */
60 5
    public function decrementBy(float $value, array $labels): self
61
    {
62 5
        static::$storage->decrement($this, $value, $labels);
63
64 5
        return $this;
65
    }
66
67
    /**
68
     * {@inheritdoc}
69
     */
70 5
    public function set(float $value, array $labels): self
71
    {
72 5
        static::$storage->set($this, $value, $labels);
73
74 5
        return $this;
75
    }
76
}
77