# decalog/4.4.0/includes/libraries/prometheus/Counter.php

DecaLog, version 4.4.0. 50 lines.

- Page: https://pluginprobe.com/plugins/decalog/4.4.0/code/includes/libraries/prometheus/Counter.php
- Raw: https://pluginprobe.com/plugins/decalog/4.4.0/raw/includes/libraries/prometheus/Counter.php
- Modified: 2021-06-22T11:43:48+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/decalog/4.4.0/code/includes/libraries/prometheus/Counter.php#L10-L20`.

```php
<?php

declare(strict_types=1);

namespace Prometheus;

use Prometheus\Storage\Adapter;

class Counter extends Collector
{
    const TYPE = 'counter';

    /**
     * @return string
     */
    public function getType(): string
    {
        return self::TYPE;
    }

    /**
     * @param string[] $labels e.g. ['status', 'opcode']
     */
    public function inc(array $labels = []): void
    {
        $this->incBy(1, $labels);
    }

    /**
     * @param int|float $count e.g. 2
     * @param mixed[] $labels e.g. ['status', 'opcode']
     */
    public function incBy($count, array $labels = []): void
    {
        $this->assertLabelsAreDefinedCorrectly($labels);

        $this->storageAdapter->updateCounter(
            [
                'name' => $this->getName(),
                'help' => $this->getHelp(),
                'type' => $this->getType(),
                'labelNames' => $this->getLabelNames(),
                'labelValues' => $labels,
                'value' => $count,
                'command' => is_float($count) ? Adapter::COMMAND_INCREMENT_FLOAT : Adapter::COMMAND_INCREMENT_INTEGER,
            ]
        );
    }
}

```
