Passed
Push — master ( 35c21b...a82c2e )
by SignpostMarv
12:21
created

AvailabilityAndStartsAndEnds::SetAvailability()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 1
dl 0
loc 7
ccs 6
cts 6
cp 1
crap 1
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\Intangible\Enumeration\ItemAvailability;
11
use SignpostMarv\DaftObject\SchemaOrg\TypeUtilities;
12
13
trait AvailabilityAndStartsAndEnds
14
{
15
    use DaftObjectTrait;
16
17
    /**
18
    * @return array<int, ItemAvailability>
19
    */
20 88
    public function GetAvailability() : array
21
    {
22
        /**
23
        * @var array<int, ItemAvailability>
24
        */
25 88
        $out = TypeUtilities::ExpectRetrievedValueIsArray(
26 88
            'availability',
27 88
            $this->RetrievePropertyValueFromData('availability'),
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

27
            $this->/** @scrutinizer ignore-call */ 
28
                   RetrievePropertyValueFromData('availability'),
Loading history...
28 88
            static::class
29
        );
30
31 88
        return $out;
32
    }
33
34
    /**
35
    * @param array<int, ItemAvailability> $value
36
    */
37 2
    public function SetAvailability(array $value) : void
38
    {
39 2
        $this->NudgePropertyWithUniqueValuesOfThings(
40 2
            'availability',
41 2
            __METHOD__,
42 2
            $value,
43 2
            ItemAvailability::class
44
        );
45 2
    }
46
47
    /**
48
    * @return array<int, DateTime>
49
    */
50 88
    public function GetAvailabilityEnds() : array
51
    {
52
        /**
53
        * @var array<int, DateTime>
54
        */
55 88
        $out = TypeUtilities::ExpectRetrievedValueIsArray(
56 88
            'availabilityEnds',
57 88
            $this->RetrievePropertyValueFromData('availabilityEnds'),
58 88
            static::class
59
        );
60
61 88
        return $out;
62
    }
63
64
    /**
65
    * @param array<int, DateTime> $value
66
    */
67 2
    public function SetAvailabilityEnds(array $value) : void
68
    {
69 2
        $this->NudgePropertyWithUniqueValuesOfThings(
70 2
            'availabilityEnds',
71 2
            __METHOD__,
72 2
            $value,
73 2
            DateTime::class
74
        );
75 2
    }
76
77
    /**
78
    * @return array<int, DateTime>
79
    */
80 88
    public function GetAvailabilityStarts() : array
81
    {
82
        /**
83
        * @var array<int, DateTime>
84
        */
85 88
        $out = TypeUtilities::ExpectRetrievedValueIsArray(
86 88
            'availabilityStarts',
87 88
            $this->RetrievePropertyValueFromData('availabilityStarts'),
88 88
            static::class
89
        );
90
91 88
        return $out;
92
    }
93
94
    /**
95
    * @param array<int, DateTime> $value
96
    */
97 2
    public function SetAvailabilityStarts(array $value) : void
98
    {
99 2
        $this->NudgePropertyWithUniqueValuesOfThings(
100 2
            'availabilityStarts',
101 2
            __METHOD__,
102 2
            $value,
103 2
            DateTime::class
104
        );
105 2
    }
106
}
107