ItemAvailability   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 253
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 12
lcom 1
cbo 1
dl 253
loc 253
rs 10
c 0
b 0
f 0

12 Methods

Rating   Name   Duplication   Size   Complexity  
A additionalType() 4 4 1
A alternateName() 4 4 1
A description() 4 4 1
A disambiguatingDescription() 4 4 1
A identifier() 4 4 1
A image() 4 4 1
A mainEntityOfPage() 4 4 1
A name() 4 4 1
A potentialAction() 4 4 1
A sameAs() 4 4 1
A subjectOf() 4 4 1
A url() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Spatie\SchemaOrg;
4
5
use \Spatie\SchemaOrg\Contracts\ItemAvailabilityContract;
6
use \Spatie\SchemaOrg\Contracts\EnumerationContract;
7
use \Spatie\SchemaOrg\Contracts\IntangibleContract;
8
use \Spatie\SchemaOrg\Contracts\ThingContract;
9
10
/**
11
 * A list of possible product availability options.
12
 *
13
 * @see http://schema.org/ItemAvailability
14
 *
15
 */
16 View Code Duplication
class ItemAvailability extends BaseType implements ItemAvailabilityContract, EnumerationContract, IntangibleContract, ThingContract
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
17
{
18
    /**
19
     * Indicates that the item has been discontinued.
20
     *
21
     * @see http://schema.org/Discontinued
22
     */
23
     const Discontinued = 'http://schema.org/Discontinued';
24
25
    /**
26
     * Indicates that the item is in stock.
27
     *
28
     * @see http://schema.org/InStock
29
     */
30
     const InStock = 'http://schema.org/InStock';
31
32
    /**
33
     * Indicates that the item is available only at physical locations.
34
     *
35
     * @see http://schema.org/InStoreOnly
36
     */
37
     const InStoreOnly = 'http://schema.org/InStoreOnly';
38
39
    /**
40
     * Indicates that the item has limited availability.
41
     *
42
     * @see http://schema.org/LimitedAvailability
43
     */
44
     const LimitedAvailability = 'http://schema.org/LimitedAvailability';
45
46
    /**
47
     * Indicates that the item is available only online.
48
     *
49
     * @see http://schema.org/OnlineOnly
50
     */
51
     const OnlineOnly = 'http://schema.org/OnlineOnly';
52
53
    /**
54
     * Indicates that the item is out of stock.
55
     *
56
     * @see http://schema.org/OutOfStock
57
     */
58
     const OutOfStock = 'http://schema.org/OutOfStock';
59
60
    /**
61
     * Indicates that the item is available for pre-order.
62
     *
63
     * @see http://schema.org/PreOrder
64
     */
65
     const PreOrder = 'http://schema.org/PreOrder';
66
67
    /**
68
     * Indicates that the item is available for ordering and delivery before
69
     * general availability.
70
     *
71
     * @see http://schema.org/PreSale
72
     */
73
     const PreSale = 'http://schema.org/PreSale';
74
75
    /**
76
     * Indicates that the item has sold out.
77
     *
78
     * @see http://schema.org/SoldOut
79
     */
80
     const SoldOut = 'http://schema.org/SoldOut';
81
82
    /**
83
     * An additional type for the item, typically used for adding more specific
84
     * types from external vocabularies in microdata syntax. This is a
85
     * relationship between something and a class that the thing is in. In RDFa
86
     * syntax, it is better to use the native RDFa syntax - the 'typeof'
87
     * attribute - for multiple types. Schema.org tools may have only weaker
88
     * understanding of extra types, in particular those defined externally.
89
     *
90
     * @param string|string[] $additionalType
91
     *
92
     * @return static
93
     *
94
     * @see http://schema.org/additionalType
95
     */
96
    public function additionalType($additionalType)
97
    {
98
        return $this->setProperty('additionalType', $additionalType);
99
    }
100
101
    /**
102
     * An alias for the item.
103
     *
104
     * @param string|string[] $alternateName
105
     *
106
     * @return static
107
     *
108
     * @see http://schema.org/alternateName
109
     */
110
    public function alternateName($alternateName)
111
    {
112
        return $this->setProperty('alternateName', $alternateName);
113
    }
114
115
    /**
116
     * A description of the item.
117
     *
118
     * @param string|string[] $description
119
     *
120
     * @return static
121
     *
122
     * @see http://schema.org/description
123
     */
124
    public function description($description)
125
    {
126
        return $this->setProperty('description', $description);
127
    }
128
129
    /**
130
     * A sub property of description. A short description of the item used to
131
     * disambiguate from other, similar items. Information from other properties
132
     * (in particular, name) may be necessary for the description to be useful
133
     * for disambiguation.
134
     *
135
     * @param string|string[] $disambiguatingDescription
136
     *
137
     * @return static
138
     *
139
     * @see http://schema.org/disambiguatingDescription
140
     */
141
    public function disambiguatingDescription($disambiguatingDescription)
142
    {
143
        return $this->setProperty('disambiguatingDescription', $disambiguatingDescription);
144
    }
145
146
    /**
147
     * The identifier property represents any kind of identifier for any kind of
148
     * [[Thing]], such as ISBNs, GTIN codes, UUIDs etc. Schema.org provides
149
     * dedicated properties for representing many of these, either as textual
150
     * strings or as URL (URI) links. See [background
151
     * notes](/docs/datamodel.html#identifierBg) for more details.
152
     *
153
     * @param \Spatie\SchemaOrg\Contracts\PropertyValueContract|\Spatie\SchemaOrg\Contracts\PropertyValueContract[]|string|string[] $identifier
154
     *
155
     * @return static
156
     *
157
     * @see http://schema.org/identifier
158
     */
159
    public function identifier($identifier)
160
    {
161
        return $this->setProperty('identifier', $identifier);
162
    }
163
164
    /**
165
     * An image of the item. This can be a [[URL]] or a fully described
166
     * [[ImageObject]].
167
     *
168
     * @param \Spatie\SchemaOrg\Contracts\ImageObjectContract|\Spatie\SchemaOrg\Contracts\ImageObjectContract[]|string|string[] $image
169
     *
170
     * @return static
171
     *
172
     * @see http://schema.org/image
173
     */
174
    public function image($image)
175
    {
176
        return $this->setProperty('image', $image);
177
    }
178
179
    /**
180
     * Indicates a page (or other CreativeWork) for which this thing is the main
181
     * entity being described. See [background
182
     * notes](/docs/datamodel.html#mainEntityBackground) for details.
183
     *
184
     * @param \Spatie\SchemaOrg\Contracts\CreativeWorkContract|\Spatie\SchemaOrg\Contracts\CreativeWorkContract[]|string|string[] $mainEntityOfPage
185
     *
186
     * @return static
187
     *
188
     * @see http://schema.org/mainEntityOfPage
189
     */
190
    public function mainEntityOfPage($mainEntityOfPage)
191
    {
192
        return $this->setProperty('mainEntityOfPage', $mainEntityOfPage);
193
    }
194
195
    /**
196
     * The name of the item.
197
     *
198
     * @param string|string[] $name
199
     *
200
     * @return static
201
     *
202
     * @see http://schema.org/name
203
     */
204
    public function name($name)
205
    {
206
        return $this->setProperty('name', $name);
207
    }
208
209
    /**
210
     * Indicates a potential Action, which describes an idealized action in
211
     * which this thing would play an 'object' role.
212
     *
213
     * @param \Spatie\SchemaOrg\Contracts\ActionContract|\Spatie\SchemaOrg\Contracts\ActionContract[] $potentialAction
214
     *
215
     * @return static
216
     *
217
     * @see http://schema.org/potentialAction
218
     */
219
    public function potentialAction($potentialAction)
220
    {
221
        return $this->setProperty('potentialAction', $potentialAction);
222
    }
223
224
    /**
225
     * URL of a reference Web page that unambiguously indicates the item's
226
     * identity. E.g. the URL of the item's Wikipedia page, Wikidata entry, or
227
     * official website.
228
     *
229
     * @param string|string[] $sameAs
230
     *
231
     * @return static
232
     *
233
     * @see http://schema.org/sameAs
234
     */
235
    public function sameAs($sameAs)
236
    {
237
        return $this->setProperty('sameAs', $sameAs);
238
    }
239
240
    /**
241
     * A CreativeWork or Event about this Thing.
242
     *
243
     * @param \Spatie\SchemaOrg\Contracts\CreativeWorkContract|\Spatie\SchemaOrg\Contracts\CreativeWorkContract[]|\Spatie\SchemaOrg\Contracts\EventContract|\Spatie\SchemaOrg\Contracts\EventContract[] $subjectOf
244
     *
245
     * @return static
246
     *
247
     * @see http://schema.org/subjectOf
248
     */
249
    public function subjectOf($subjectOf)
250
    {
251
        return $this->setProperty('subjectOf', $subjectOf);
252
    }
253
254
    /**
255
     * URL of the item.
256
     *
257
     * @param string|string[] $url
258
     *
259
     * @return static
260
     *
261
     * @see http://schema.org/url
262
     */
263
    public function url($url)
264
    {
265
        return $this->setProperty('url', $url);
266
    }
267
268
}
269