| Total Complexity | 6 |
| Total Lines | 57 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | abstract class Histogram extends Metric implements Observable |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var int[] |
||
| 14 | */ |
||
| 15 | protected $buckets = [ |
||
| 16 | .005, |
||
| 17 | .01, |
||
| 18 | .025, |
||
| 19 | .05, |
||
| 20 | .1, |
||
| 21 | .25, |
||
| 22 | .5, |
||
| 23 | 1, |
||
| 24 | 2.5, |
||
| 25 | 5, |
||
| 26 | 10, |
||
| 27 | ]; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * {@inheritdoc} |
||
| 31 | */ |
||
| 32 | 16 | public function __construct() |
|
| 33 | { |
||
| 34 | 16 | parent::__construct(); |
|
| 35 | |||
| 36 | 16 | foreach ($this->labels as $label) { |
|
| 37 | 16 | if (preg_match('/^le$/', $label)) { |
|
| 38 | 16 | throw new LabelException('The label `le` is used internally to designate buckets.'); |
|
| 39 | } |
||
| 40 | } |
||
| 41 | 16 | } |
|
| 42 | |||
| 43 | /** |
||
| 44 | * {@inheritdoc} |
||
| 45 | */ |
||
| 46 | 4 | final public function type(): string |
|
| 47 | { |
||
| 48 | 4 | return 'histogram'; |
|
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * {@inheritdoc} |
||
| 53 | */ |
||
| 54 | 4 | public function observe(float $value, array $labels): self |
|
| 55 | { |
||
| 56 | 4 | static::$storage->observe($this, $value, $labels); |
|
| 57 | |||
| 58 | 4 | return $this; |
|
| 59 | } |
||
| 60 | |||
| 61 | /** |
||
| 62 | * @return Collection |
||
| 63 | */ |
||
| 64 | 11 | public function buckets(): Collection |
|
| 67 | } |
||
| 68 | } |
||
| 69 |