GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 11139b...2b076b )
by Dominic
03:41
created

Metric::getData()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 3

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 16
ccs 10
cts 10
cp 1
rs 9.4286
cc 3
eloc 8
nc 2
nop 0
crap 3
1
<?php
2
3
namespace Vend\Statsd\Datadog;
4
5
use Vend\Statsd\Metric as BaseMetric;
6
7
class Metric extends BaseMetric
8
{
9
    /**
10
     * @var array<string,string>
11
     */
12
    protected $tags = [];
13
14 7
    public function __construct($key, $value, $type, array $tags = [])
15
    {
16 7
        parent::__construct($key, $value, $type);
17
18 7
        $this->setTags($tags);
19 7
    }
20
21 7
    public function setTags(array $tags = [])
22
    {
23 7
        $this->tags = $tags;
24 7
    }
25
26 7
    public function getData()
27
    {
28 7
        $result = parent::getData();
29
30 7
        if (!empty($this->tags)) {
31 1
            $tags = [];
32
33 1
            array_walk($this->tags, function ($tagValue, $tagName) use (&$tags) {
34 1
                $tags[] = is_integer($tagName) ? $tagValue : $tagName . ':' . $tagValue;
35 1
            });
36
37 1
            $result .= '|#' . implode(',', $tags);
38 1
        }
39
40 7
        return $result;
41
    }
42
}
43