Passed
Push — master ( b7b55a...a74c74 )
by SignpostMarv
11:14
created

IsRelatedOrSimilarTo   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 24
dl 0
loc 63
ccs 27
cts 27
cp 1
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A GetIsRelatedTo() 0 12 1
A GetIsSimilarTo() 0 12 1
A SetIsSimilarTo() 0 8 1
A SetIsRelatedTo() 0 8 1
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\Intangible\Service;
10
use SignpostMarv\DaftObject\SchemaOrg\Product;
11
use SignpostMarv\DaftObject\SchemaOrg\TypeUtilities;
12
13
trait IsRelatedOrSimilarTo
14
{
15
    use DaftObjectTrait;
16
17
    /**
18
    * @return array<int, Product|Service>
19
    */
20 72
    public function GetIsRelatedTo() : array
21
    {
22
        /**
23
        * @var array<int, Product|Service>
24
        */
25 72
        $out = TypeUtilities::ExpectRetrievedValueIsArray(
26 72
            'isRelatedTo',
27 72
            $this->RetrievePropertyValueFromData('isRelatedTo'),
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('isRelatedTo'),
Loading history...
28 72
            static::class
29
        );
30
31 72
        return $out;
32
    }
33
34
    /**
35
    * @param array<int, Product|Service> $value
36
    */
37 2
    public function SetIsRelatedTo(array $value) : void
38
    {
39 2
        $this->NudgePropertyWithUniqueValuesOfThings(
40 2
            'isRelatedTo',
41 2
            __METHOD__,
42 2
            $value,
43 2
            Product::class,
44 2
            Service::class
45
        );
46 2
    }
47
48
    /**
49
    * @return array<int, Product|Service>
50
    */
51 72
    public function GetIsSimilarTo() : array
52
    {
53
        /**
54
        * @var array<int, Product|Service>
55
        */
56 72
        $out = TypeUtilities::ExpectRetrievedValueIsArray(
57 72
            'isSimilarTo',
58 72
            $this->RetrievePropertyValueFromData('isSimilarTo'),
59 72
            static::class
60
        );
61
62 72
        return $out;
63
    }
64
65
    /**
66
    * @param array<int, Product|Service> $value
67
    */
68 2
    public function SetIsSimilarTo(array $value) : void
69
    {
70 2
        $this->NudgePropertyWithUniqueValuesOfThings(
71 2
            'isSimilarTo',
72 2
            __METHOD__,
73 2
            $value,
74 2
            Product::class,
75 2
            Service::class
76
        );
77 2
    }
78
}
79