Passed
Push — master ( 90d129...206775 )
by SignpostMarv
03:53
created

HasValidFromThrough::GetValidThrough()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 12
ccs 0
cts 6
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
* @author SignpostMarv
4
*/
5
declare(strict_types=1);
6
7
namespace SignpostMarv\DaftObject\SchemaOrg\DaftObjectTraits;
8
9
use SignpostMarv\DaftObject\SchemaOrg\DataTypes\DateTime;
10
use SignpostMarv\DaftObject\SchemaOrg\TypeUtilities;
11
12
trait HasValidFromThrough
13
{
14
    use DaftObjectTrait;
15
16
    /**
17
    * @return array<int, DateTime>
18
    */
19
    public function GetValidFrom() : array
20
    {
21
        /**
22
        * @var array<int, DateTime>
23
        */
24
        $out = TypeUtilities::ExpectRetrievedValueIsArray(
25
            'validFrom',
26
            $this->RetrievePropertyValueFromData('validFrom'),
0 ignored issues
show
Bug introduced by
It seems like RetrievePropertyValueFromData() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

26
            $this->/** @scrutinizer ignore-call */ 
27
                   RetrievePropertyValueFromData('validFrom'),
Loading history...
27
            static::class
28
        );
29
30
        return $out;
31
    }
32
33
    /**
34
    * @param array<int, DateTime> $value
35
    */
36
    public function SetValidFrom(array $value) : void
37
    {
38
        $this->NudgePropertyWithUniqueValuesOfThings(
39
            'validFrom',
40
            __METHOD__,
41
            $value,
42
            DateTime::class
43
        );
44
    }
45
46
    /**
47
    * @return array<int, DateTime>
48
    */
49
    public function GetValidThrough() : array
50
    {
51
        /**
52
        * @var array<int, DateTime>
53
        */
54
        $out = TypeUtilities::ExpectRetrievedValueIsArray(
55
            'validThrough',
56
            $this->RetrievePropertyValueFromData('validThrough'),
57
            static::class
58
        );
59
60
        return $out;
61
    }
62
63
    /**
64
    * @param array<int, DateTime> $value
65
    */
66
    public function SetValidThrough(array $value) : void
67
    {
68
        $this->NudgePropertyWithUniqueValuesOfThings(
69
            'validThrough',
70
            __METHOD__,
71
            $value,
72
            DateTime::class
73
        );
74
    }
75
}
76