GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

FacebookProductItem::category()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
namespace Bhaktaraz\RSSGenerator;
4
5
use Bhaktaraz\RSSGenerator\ItemInterface;
6
use Bhaktaraz\RSSGenerator\ChannelInterface;
7
use Bhaktaraz\RSSGenerator\SimpleXMLElement;
8
9
class FacebookProductItem implements ItemInterface
10
{
11
    /** @var integer */
12
    protected $id;
13
14
    /** @var string */
15
    protected $title;
16
17
    /** @var string */
18
    protected $url;
19
20
    /** @var string */
21
    protected $availability;
22
23
    /** @var string */
24
    protected $condition;
25
26
    /** @var string */
27
    protected $price;
28
29
    /** @var string */
30
    protected $googleProductCategory;
31
32
    /** @var string */
33
    protected $imageLink;
34
35
    /** @var string */
36
    protected $description;
37
38
    /** @var string */
39
    protected $brand;
40
41
    /** @var  string */
42
    protected $content;
43
44
    /** @var  string */
45
    protected $creator;
46
47
    /** @var array */
48
    protected $categories = [];
49
50
    /** @var string */
51
    protected $guid;
52
53
    /** @var bool */
54
    protected $isPermalink;
55
56
    /** @var int */
57
    protected $pubDate;
58
59
    /** @var array */
60
    protected $enclosure;
61
62
    /**
63
     * Set item id
64
     * @param integer $id
65
     * @return $this
66
     */
67
    public function id($id)
68
    {
69
        $this->id = $id;
70
71
        return $this;
72
    }
73
74
    /**
75
     * Set item title
76
     * @param string $title
77
     * @return $this
78
     */
79
    public function title($title)
80
    {
81
        $this->title = $title;
82
83
        return $this;
84
    }
85
86
    /**
87
     * Set item URL
88
     * @param string $url
89
     * @return $this
90
     */
91
    public function url($url)
92
    {
93
        $this->url = $url;
94
95
        return $this;
96
    }
97
98
    /**
99
     * Set item description
100
     * @param string $description
101
     * @return $this
102
     */
103
    public function description($description)
104
    {
105
        $this->description = $description;
106
107
        return $this;
108
    }
109
110
    /**
111
     * Set item brand
112
     * @param string $brand
113
     * @return $this
114
     */
115
    public function brand($brand)
116
    {
117
        $this->brand = $brand;
118
119
        return $this;
120
    }
121
122
    /**
123
     * Set item availability
124
     * @param string $availability
125
     * @return $this
126
     */
127
    public function availability($availability)
128
    {
129
        $this->availability = $availability;
130
131
        return $this;
132
    }
133
134
    /**
135
     * Set item condition
136
     * @param string $condition
137
     * @return $this
138
     */
139
    public function condition($condition)
140
    {
141
        $this->condition = $condition;
142
143
        return $this;
144
    }
145
146
    /**
147
     * Set item price
148
     * @param string $price
149
     * @return $this
150
     */
151
    public function price($price)
152
    {
153
        $this->price = $price;
154
155
        return $this;
156
    }
157
158
    /**
159
     * Set item googleProductCategory
160
     * @param string $googleProductCategory
161
     * @return $this
162
     */
163
    public function googleProductCategory($googleProductCategory)
164
    {
165
        $this->googleProductCategory = $googleProductCategory;
166
167
        return $this;
168
    }
169
170
    /**
171
     * Set item imageLink
172
     * @param string $imageLink
173
     * @return $this
174
     */
175
    public function imageLink($imageLink)
176
    {
177
        $this->imageLink = $imageLink;
178
179
        return $this;
180
    }
181
182
183
    /**
184
     * Set item category
185
     * @param string $name Category name
186
     * @param string $domain Category URL
187
     * @return $this
188
     */
189
    public function category($name, $domain = null)
190
    {
191
        $this->categories[] = [$name, $domain];
192
193
        return $this;
194
    }
195
196
    /**
197
     * Set GUID
198
     * @param string $guid
199
     * @param bool $isPermalink
200
     * @return $this
201
     */
202
    public function guid($guid, $isPermalink = false)
203
    {
204
        $this->guid = $guid;
205
        $this->isPermalink = $isPermalink;
206
207
        return $this;
208
    }
209
210
    /**
211
     * Set published date
212
     * @param int $pubDate Unix timestamp
213
     * @return $this
214
     */
215
    public function pubDate($pubDate)
216
    {
217
        $this->pubDate = $pubDate;
218
219
        return $this;
220
    }
221
222
    /**
223
     * Set enclosure
224
     * @param string $url Url to media file
225
     * @param int $length Length in bytes of the media file
226
     * @param string $type Media type, default is audio/mpeg
227
     * @return $this
228
     */
229
    public function enclosure($url, $length = 0, $type = 'audio/mpeg')
230
    {
231
        $this->enclosure = ['url' => $url, 'length' => $length, 'type' => $type];
232
233
        return $this;
234
    }
235
236
    /**
237
     * Append item to the channel
238
     * @param ChannelInterface $channel
239
     * @return $this
240
     */
241
    public function appendTo(ChannelInterface $channel)
242
    {
243
        $channel->addItem($this);
244
245
        return $this;
246
    }
247
248
    /**
249
     * Set author name for article
250
     *
251
     * @param $creator
252
     * @return $this
253
     */
254
    public function creator($creator)
255
    {
256
        $this->creator = $creator;
257
258
        return $this;
259
    }
260
261
    /**
262
     * @param $content
263
     * @return $this
264
     */
265
    public function content($content)
266
    {
267
        $this->content = $content;
268
269
        return $this;
270
    }
271
272
    /**
273
     * Return XML object
274
     * @return SimpleXMLElement
275
     */
276
    public function asXML()
277
    {
278
        $xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8" ?><item></item>', LIBXML_NOERROR | LIBXML_ERR_NONE | LIBXML_ERR_FATAL);
279
280
        $xml->addChild('g:id', $this->title, 'http://base.google.com/ns/1.0');
281
        $xml->addChild('g:title', $this->title, 'http://base.google.com/ns/1.0');
282
        $xml->addChild('g:link', $this->url, 'http://base.google.com/ns/1.0');
283
        $xml->addChild('g:description', $this->description, 'http://base.google.com/ns/1.0');
284
        $xml->addChild('g:availability', $this->availability, 'http://base.google.com/ns/1.0');
285
        $xml->addChild('g:price', $this->price, 'http://base.google.com/ns/1.0');
286
        $xml->addChild('g:condition', $this->condition, 'http://base.google.com/ns/1.0');
287
        $xml->addChild('g:google_product_category', $this->googleProductCategory, 'http://base.google.com/ns/1.0');
288
        $xml->addChild('g:image_link', $this->imageLink, 'http://base.google.com/ns/1.0');
289
        $xml->addChild('g:brand', $this->brand, 'http://base.google.com/ns/1.0');
290
291
        return $xml;
292
    }
293
}
294