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

TimestampSpec   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 13
c 0
b 0
f 0
dl 0
loc 33
ccs 11
cts 11
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A toArray() 0 12 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
}