Passed
Pull Request — master (#38)
by Teye
05:43
created

TimestampSpec::toArray()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 6
c 0
b 0
f 0
dl 0
loc 12
ccs 7
cts 7
cp 1
rs 10
cc 2
nc 2
nop 0
crap 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Level23\Druid\Dimensions;
5
6
class TimestampSpec
7
{
8
    protected string $column;
9
10
    protected string $format;
11
12
    /**
13
     * @var string|null
14
     */
15
    protected ?string $missingValue = null;
16
17 12
    public function __construct(string $column, string $format, ?string $missingValue = null)
18
    {
19 12
        $this->column       = $column;
20 12
        $this->format       = $format;
21 12
        $this->missingValue = $missingValue;
22
    }
23
24
    /**
25
     * @return array<string,string>
26
     */
27 3
    public function toArray(): array
28
    {
29 3
        $response = [
30 3
            'column' => $this->column,
31 3
            'format' => $this->format,
32
        ];
33
34 3
        if (!empty($this->missingValue)) {
35 1
            $response['missingValue'] = $this->missingValue;
36
        }
37
38 3
        return $response;
39
    }
40
}