Completed
Push — master ( 2fb104...0c9ed9 )
by Basil
03:25
created

Rating::getBestRating()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace luya\web\jsonld;
4
5
use luya\helpers\ObjectHelper;
6
use yii\base\InvalidConfigException;
7
8
9
/**
10
 * JsonLd Rating.
11
 *
12
 * @see http://schema.org/Rating
13
 * @author Basil Suter <[email protected]>
14
 * @since 1.0.3
15
 */
16
class Rating extends BaseThing
17
{
18
    /**
19
     * @inheritdoc
20
     */
21
    public function typeDefintion()
22
    {
23
        return 'Rating';
24
    }
25
26
    private $_author;
27
28
    /**
29
     * Set Author
30
     * 
31
     * The author of this content or rating. Please note that author is special in that HTML 5 provides a special mechanism for indicating authorship via the rel tag. That is equivalent to this and may be used interchangeably.
32
     *
33
     * @param Organization|Person $author
34
     * @return static
35
     */
36
    public function setAuthor($author)
37
    {
38
        ObjectHelper::isInstanceOf($author, [Organization::class, Person::class]);
0 ignored issues
show
Documentation introduced by
$author is of type object<luya\web\jsonld\O...luya\web\jsonld\Person>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
39
        $this->_author = $author;
40
        return $this;
41
    }
42
43
    /**
44
     * Get Author
45
     *
46
     * @return Organization|Person
47
     */
48
    public function getAuthor()
49
    {
50
        return $this->_author;
51
    }
52
53
    private $_bestRating;
54
55
    /**
56
     * Set best Rating.
57
     * 
58
     * The highest value allowed in this rating system. If bestRating is omitted, 5 is assumed.
59
     *
60
     * @param RangeValue $bestRating
61
     * @return static
62
     */
63
    public function setBestRating(RangeValue $bestRating)
64
    {
65
        $bestRating->ensureRange(1,5);
66
        $this->_bestRating = $bestRating->getValue();
67
        return $this;
68
    }
69
70
    /**
71
     * Get best rating
72
     *
73
     * @return integer
74
     */
75
    public function getBestRating()
76
    {
77
        return $this->_bestRating;
78
    }
79
80
    private $_ratingValue;
81
82
    /**
83
     * Set Rating Value.
84
     * 
85
     * The rating for the content.
86
     *
87
     * @param RangeValue $ratingValue
88
     * @return static
89
     */
90
    public function setRatingValue(RangeValue $ratingValue)
91
    {
92
        $ratingValue->ensureRange(1,5);
93
        $this->_ratingValue = $ratingValue->getValue();
94
        return $this;
95
    }
96
97
    /**
98
     * Get Rating Value.
99
     *
100
     * @return integer
101
     */
102
    public function getRatingValue()
103
    {
104
        return $this->_ratingValue;
105
    }
106
    
107
    private $_reviewAspect;
108
109
    /**
110
     * Set Review Aspect.
111
     * 
112
     * This Review or Rating is relevant to this part or facet of the itemReviewed.
113
     *
114
     * @param string $reviewAspect
115
     * @return static
116
     */
117
    public function setReviewAspect($reviewAspect)
118
    {
119
        $this->_reviewAspect = $reviewAspect;
120
        return $this;
121
    }
122
123
    /**
124
     * Get Review Aspect.
125
     *
126
     * @return string
127
     */
128
    public function getReviewAspect()
129
    {
130
        return $this->_reviewAspect;
131
    }
132
133
    private $_worstRating;
134
135
    /**
136
     * Set Worst Rating.
137
     *
138
     * The lowest value allowed in this rating system. If worstRating is omitted, 1 is assumed.
139
     * 
140
     * @param RangeValue $worstRating
141
     * @return static
142
     */
143
    public function setWorstRating(RangeValue $worstRating)
144
    {
145
        $worstRating->ensureRange(1,5);
146
        $this->_worstRating = $worstRating->getValue();
147
        return $this;
148
    }
149
150
    /**
151
     * Get Worst Rating
152
     *
153
     * @return integer
154
     */
155
    public function getWorstRating()
156
    {
157
        return $this->_worstRating;
158
    }
159
}
160