Completed
Pull Request — master (#14)
by Sergey
02:24
created

ExtensionTrait::setMetricsPrefix()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php namespace ChaseConey\LaravelDatadogHelper\Datadog;
2
3
trait ExtensionTrait
4
{
5
    protected $metricsPrefix;
6
7
    public function setMetricsPrefix($metricsPrefix)
8
    {
9
        $this->metricsPrefix = $metricsPrefix;
10
    }
11
12
    protected function wrapSendDataWithMetricPrefix($data)
13
    {
14
        if (!$this->metricsPrefix) {
15
            return $data;
16
        }
17
18
        $wrapped = [];
19
        foreach ($data as $metric => $stat) {
20
            $wrapped[$this->metricsPrefix . '.'. $metric] = $stat;
21
        }
22
        return $wrapped;
23
    }
24
}
25