HasSegmentGranularity::segmentGranularity()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 10
c 1
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Level23\Druid\Concerns;
5
6
use Level23\Druid\Types\Granularity;
7
8
trait HasSegmentGranularity
9
{
10
    /**
11
     * @var null|Granularity
12
     */
13
    protected ?Granularity $segmentGranularity = null;
14
15
    /**
16
     * @param string|Granularity $segmentGranularity
17
     *
18
     * @return $this
19
     */
20 13
    public function segmentGranularity(string|Granularity $segmentGranularity): self
21
    {
22 13
        $this->segmentGranularity = is_string($segmentGranularity) ? Granularity::from(strtolower($segmentGranularity)) : $segmentGranularity;
23
24 13
        return $this;
25
    }
26
}