Completed
Pull Request — master (#563)
by Richard
08:33
created

RssCopyrightHandler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 26
loc 26
rs 10
c 0
b 0
f 0
ccs 0
cts 14
cp 0
wmc 3
lcom 0
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handleCharacterData() 0 8 2
A getName() 0 3 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
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
*/
11
12
/**
13
 * @category   Class
14
 * @package    Xml
15
 * @author     Kazumi Ono (AKA onokazu)
16
 * @copyright  2000-2016 XOOPS Project (http://xoops.org)
17
 * @license    GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
18
 * @link        http://xoops.org
19
 * @since       1.0.0
20
 */
21
class XoopsXmlRss2Parser extends SaxParser
22
{
23
    /**
24
     * @var array
25
     */
26
    private $_tempArr = array();
27
28
    /**
29
     * @var array
30
     */
31
    private $_channelData = array();
32
33
    /**
34
     * @var array
35
     */
36
    private $_imageData = array();
37
38
    /**
39
     * @var array
40
     */
41
    private $_items = array();
42
43
    /**
44
     * XoopsXmlRss2Parser constructor.
45
     * @param string $input xml document to parse
46
     */
47
    public function __construct(&$input)
48
    {
49
        parent::__construct($input);
50
        $this->useUtfEncoding();
51
        $this->addTagHandler(new RssChannelHandler());
52
        $this->addTagHandler(new RssTitleHandler());
53
        $this->addTagHandler(new RssLinkHandler());
54
        $this->addTagHandler(new RssGeneratorHandler());
55
        $this->addTagHandler(new RssDescriptionHandler());
56
        $this->addTagHandler(new RssCopyrightHandler());
57
        $this->addTagHandler(new RssNameHandler());
58
        $this->addTagHandler(new RssManagingEditorHandler());
59
        $this->addTagHandler(new RssLanguageHandler());
60
        $this->addTagHandler(new RssLastBuildDateHandler());
61
        $this->addTagHandler(new RssWebMasterHandler());
62
        $this->addTagHandler(new RssImageHandler());
63
        $this->addTagHandler(new RssUrlHandler());
64
        $this->addTagHandler(new RssWidthHandler());
65
        $this->addTagHandler(new RssHeightHandler());
66
        $this->addTagHandler(new RssItemHandler());
67
        $this->addTagHandler(new RssCategoryHandler());
68
        $this->addTagHandler(new RssPubDateHandler());
69
        $this->addTagHandler(new RssCommentsHandler());
70
        $this->addTagHandler(new RssSourceHandler());
71
        $this->addTagHandler(new RssAuthorHandler());
72
        $this->addTagHandler(new RssGuidHandler());
73
        $this->addTagHandler(new RssTextInputHandler());
74
    }
75
76
    /**
77
     * @param string $name  channel name
78
     * @param string $value value
79
     * @return void
80
     */
81
    public function setChannelData($name, &$value)
82
    {
83
        if (!isset($this->_channelData[$name])) {
84
            $this->_channelData[$name] = $value;
85
        } else {
86
            $this->_channelData[$name] .= $value;
87
        }
88
    }
89
90
    /**
91
     * @param string $name channel name
92
     * @return array|bool
93
     */
94
    public function getChannelData($name = null)
95
    {
96
        if (isset($name)) {
97
            if (isset($this->_channelData[$name])) {
98
                return $this->_channelData[$name];
99
            }
100
            return false;
101
        }
102
        return $this->_channelData;
103
    }
104
105
    /**
106
     * @param string $name  image data name
107
     * @param string $value value
108
     * @return void
109
     */
110
    public function setImageData($name, &$value)
111
    {
112
        $this->_imageData[$name] = $value;
113
    }
114
115
    /**
116
     * @param string $name image data name
117
     * @return array|bool
118
     */
119
    public function getImageData($name = null)
120
    {
121
        if (isset($name)) {
122
            if (isset($this->_imageData[$name])) {
123
                return $this->_imageData[$name];
124
            }
125
            $return = false;
126
            return $return;
127
        }
128
        return $this->_imageData;
129
    }
130
131
    /**
132
     * @param array $itemarr
133
     * @return void
134
     */
135
    public function setItems(&$itemarr)
136
    {
137
        $this->_items[] = $itemarr;
138
    }
139
140
    /**
141
     * @return array
142
     */
143
    public function getItems()
144
    {
145
        return $this->_items;
146
    }
147
148
    /**
149
     * @param string $name
150
     * @param array  $value
151
     * @param string $delim
152
     * @return void
153
     */
154
    public function setTempArr($name, &$value, $delim = '')
155
    {
156
        if (!isset($this->_tempArr[$name])) {
157
            $this->_tempArr[$name] = $value;
158
        } else {
159
            $this->_tempArr[$name] .= $delim . $value;
0 ignored issues
show
Bug introduced by
Are you sure $value of type array can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

159
            $this->_tempArr[$name] .= $delim . /** @scrutinizer ignore-type */ $value;
Loading history...
160
        }
161
    }
162
163
    /**
164
     * @return array
165
     */
166
    public function getTempArr()
167
    {
168
        return $this->_tempArr;
169
    }
170
171
    /**
172
     * @return void
173
     */
174
    public function resetTempArr()
175
    {
176
        unset($this->_tempArr);
177
        $this->_tempArr = array();
178
    }
179
}
180
181
/**
182
 * Class RssChannelHandler
183
 */
184
class RssChannelHandler extends XmlTagHandler
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
185
{
186
    /**
187
     * @return string
188
     */
189
    public function getName()
190
    {
191
        return 'channel';
192
    }
193
}
194
195
/**
196
 * Class RssTitleHandler
197
 */
198
class RssTitleHandler extends XmlTagHandler
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
199
{
200
    /**
201
     * @return string
202
     */
203
    public function getName()
204
    {
205
        return 'title';
206
    }
207
208
    /**
209
     * @param XoopsXmlRss2Parser $parser parser
210
     * @param array              $data
211
     * @return void
212
     */
213
    public function handleCharacterData(SaxParser $parser, &$data)
214
    {
215
        switch ($parser->getParentTag()) {
216
            case 'channel':
217
                $parser->setChannelData('title', $data);
0 ignored issues
show
Bug introduced by
The method setChannelData() does not exist on SaxParser. It seems like you code against a sub-type of SaxParser such as XoopsXmlRss2Parser. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

217
                $parser->/** @scrutinizer ignore-call */ 
218
                         setChannelData('title', $data);
Loading history...
218
                break;
219
            case 'image':
220
                $parser->setImageData('title', $data);
0 ignored issues
show
Bug introduced by
The method setImageData() does not exist on SaxParser. It seems like you code against a sub-type of SaxParser such as XoopsXmlRss2Parser. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

220
                $parser->/** @scrutinizer ignore-call */ 
221
                         setImageData('title', $data);
Loading history...
221
                break;
222
            case 'item':
223
            case 'textInput':
224
                $parser->setTempArr('title', $data);
0 ignored issues
show
Bug introduced by
The method setTempArr() does not exist on SaxParser. It seems like you code against a sub-type of said class. However, the method does not exist in XoopsXmlRpcParser. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

224
                $parser->/** @scrutinizer ignore-call */ 
225
                         setTempArr('title', $data);
Loading history...
225
                break;
226
            default:
227
                break;
228
        }
229
    }
230
}
231
232
/**
233
 * Class RssLinkHandler
234
 */
235
class RssLinkHandler extends XmlTagHandler
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
236
{
237
    /**
238
     * @return string
239
     */
240
    public function getName()
241
    {
242
        return 'link';
243
    }
244
245
    /**
246
     * @param XoopsXmlRss2Parser $parser parser
247
     * @param array              $data
248
     * @return void
249
     */
250
    public function handleCharacterData(SaxParser $parser, &$data)
251
    {
252
        switch ($parser->getParentTag()) {
253
            case 'channel':
254
                $parser->setChannelData('link', $data);
255
                break;
256
            case 'image':
257
                $parser->setImageData('link', $data);
258
                break;
259
            case 'item':
260
            case 'textInput':
261
                $parser->setTempArr('link', $data);
262
                break;
263
            default:
264
                break;
265
        }
266
    }
267
}
268
269
/**
270
 * Class RssDescriptionHandler
271
 */
272
class RssDescriptionHandler extends XmlTagHandler
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
273
{
274
    /**
275
     * @return string
276
     */
277
    public function getName()
278
    {
279
        return 'description';
280
    }
281
282
    /**
283
     * @param XoopsXmlRss2Parser $parser parser
284
     * @param array              $data
285
     * @return void
286
     */
287
    public function handleCharacterData(SaxParser $parser, &$data)
288
    {
289
        switch ($parser->getParentTag()) {
290
            case 'channel':
291
                $parser->setChannelData('description', $data);
292
                break;
293
            case 'image':
294
                $parser->setImageData('description', $data);
295
                break;
296
            case 'item':
297
            case 'textInput':
298
                $parser->setTempArr('description', $data);
299
                break;
300
            default:
301
                break;
302
        }
303
    }
304
}
305
306
/**
307
 * Class RssGeneratorHandler
308
 */
309
class RssGeneratorHandler extends XmlTagHandler
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
310
{
311
312
    /**
313
     * @return string
314
     */
315
    public function getName()
316
    {
317
        return 'generator';
318
    }
319
320
    /**
321
     * @param XoopsXmlRss2Parser $parser parser
322
     * @param array              $data
323
     * @return void
324
     */
325
    public function handleCharacterData(SaxParser $parser, &$data)
326
    {
327
        switch ($parser->getParentTag()) {
328
            case 'channel':
329
                $parser->setChannelData('generator', $data);
330
                break;
331
            default:
332
                break;
333
        }
334
    }
335
}
336
337
/**
338
 * Class RssCopyrightHandler
339
 */
340
class RssCopyrightHandler extends XmlTagHandler
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
341
{
342
    /**
343
     * @return string
344
     */
345
    public function getName()
346
    {
347
        return 'copyright';
348
    }
349
350
    /**
351
     * @param XoopsXmlRss2Parser $parser parser
352
     * @param array              $data   data
353
     * @return void
354
     */
355
    public function handleCharacterData(SaxParser $parser, &$data)
356
    {
357
        switch ($parser->getParentTag()) {
358
            case 'channel':
359
                $parser->setChannelData('copyright', $data);
360
                break;
361
            default:
362
                break;
363
        }
364
    }
365
}
366
367
/**
368
 * Class RssNameHandler
369
 */
370
class RssNameHandler extends XmlTagHandler
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
371
{
372
    /**
373
     * @return string
374
     */
375
    public function getName()
376
    {
377
        return 'name';
378
    }
379
380
    /**
381
     * @param XoopsXmlRss2Parser $parser parser
382
     * @param array $data
383
     * @return void
384
     */
385
    public function handleCharacterData(SaxParser $parser, &$data)
386
    {
387
        switch ($parser->getParentTag()) {
388
            case 'textInput':
389
                $parser->setTempArr('name', $data);
390
                break;
391
            default:
392
                break;
393
        }
394
    }
395
}
396
397
/**
398
 * Class RssManagingEditorHandler
399
 */
400
class RssManagingEditorHandler extends XmlTagHandler
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
401
{
402
403
    /**
404
     * @return string
405
     */
406
    public function getName()
407
    {
408
        return 'managingEditor';
409
    }
410
411
    /**
412
     * @param XoopsXmlRss2Parser $parser parser
413
     * @param array $data
414
     * @return void
415
     */
416
    public function handleCharacterData(SaxParser $parser, &$data)
417
    {
418
        switch ($parser->getParentTag()) {
419
            case 'channel':
420
                $parser->setChannelData('editor', $data);
421
                break;
422
            default:
423
                break;
424
        }
425
    }
426
}
427
428
/**
429
 * Class RssLanguageHandler
430
 */
431
class RssLanguageHandler extends XmlTagHandler
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
432
{
433
434
    /**
435
     * @return string
436
     */
437
    public function getName()
438
    {
439
        return 'language';
440
    }
441
442
    /**
443
     * @param XoopsXmlRss2Parser $parser parser
444
     * @param array $data
445
     * @return void
446
     */
447
    public function handleCharacterData(SaxParser $parser, &$data)
448
    {
449
        switch ($parser->getParentTag()) {
450
            case 'channel':
451
                $parser->setChannelData('language', $data);
452
                break;
453
            default:
454
                break;
455
        }
456
    }
457
}
458
459
/**
460
 * Class RssWebMasterHandler
461
 */
462
class RssWebMasterHandler extends XmlTagHandler
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
463
{
464
    /**
465
     * @return string
466
     */
467
    public function getName()
468
    {
469
        return 'webMaster';
470
    }
471
472
    /**
473
     * @param XoopsXmlRss2Parser $parser parser
474
     * @param array $data
475
     * @return void
476
     */
477
    public function handleCharacterData(SaxParser $parser, &$data)
478
    {
479
        switch ($parser->getParentTag()) {
480
            case 'channel':
481
                $parser->setChannelData('webmaster', $data);
482
                break;
483
            default:
484
                break;
485
        }
486
    }
487
}
488
489
/**
490
 * Class RssDocsHandler
491
 */
492
class RssDocsHandler extends XmlTagHandler
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
493
{
494
    /**
495
     * @return string
496
     */
497
    public function getName()
498
    {
499
        return 'docs';
500
    }
501
502
    /**
503
     * @param XoopsXmlRss2Parser $parser parser
504
     * @param array $data
505
     * @return void
506
     */
507
    public function handleCharacterData(SaxParser $parser, &$data)
508
    {
509
        switch ($parser->getParentTag()) {
510
            case 'channel':
511
                $parser->setChannelData('docs', $data);
512
                break;
513
            default:
514
                break;
515
        }
516
    }
517
}
518
519
/**
520
 * Class RssTtlHandler
521
 */
522
class RssTtlHandler extends XmlTagHandler
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
523
{
524
    /**
525
     * @return string
526
     */
527
    public function getName()
528
    {
529
        return 'ttl';
530
    }
531
532
    /**
533
     * @param XoopsXmlRss2Parser $parser parser
534
     * @param array $data
535
     * @return void
536
     */
537
    public function handleCharacterData(SaxParser $parser, &$data)
538
    {
539
        switch ($parser->getParentTag()) {
540
            case 'channel':
541
                $parser->setChannelData('ttl', $data);
542
                break;
543
            default:
544
                break;
545
        }
546
    }
547
}
548
549
/**
550
 * Class RssTextInputHandler
551
 */
552
class RssTextInputHandler extends XmlTagHandler
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
553
{
554
    /**
555
     * @return string
556
     */
557
    public function getName()
558
    {
559
        return 'textInput';
560
    }
561
562
    /**
563
     * @param XoopsXmlRss2Parser $parser parser
564
     * @param array $attributes
565
     * @return void
566
     */
567
    public function handleBeginElement(SaxParser $parser, &$attributes)
568
    {
569
        $parser->resetTempArr();
0 ignored issues
show
Bug introduced by
The method resetTempArr() does not exist on SaxParser. It seems like you code against a sub-type of said class. However, the method does not exist in XoopsXmlRpcParser. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

569
        $parser->/** @scrutinizer ignore-call */ 
570
                 resetTempArr();
Loading history...
570
    }
571
572
    /**
573
     * @param XoopsXmlRss2Parser $parser parser
574
     * @return void
575
     */
576
    public function handleEndElement(SaxParser $parser)
577
    {
578
        $parser->setChannelData('textinput', $parser->getTempArr());
0 ignored issues
show
Bug introduced by
The method getTempArr() does not exist on SaxParser. It seems like you code against a sub-type of said class. However, the method does not exist in XoopsXmlRpcParser. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

578
        $parser->setChannelData('textinput', $parser->/** @scrutinizer ignore-call */ getTempArr());
Loading history...
579
    }
580
}
581
582
/**
583
 * Class RssLastBuildDateHandler
584
 */
585
class RssLastBuildDateHandler extends XmlTagHandler
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
586
{
587
    /**
588
     * @return string
589
     */
590
    public function getName()
591
    {
592
        return 'lastBuildDate';
593
    }
594
595
    /**
596
     * @param XoopsXmlRss2Parser $parser parser
597
     * @param array $data
598
     * @return void
599
     */
600
    public function handleCharacterData(SaxParser $parser, &$data)
601
    {
602
        switch ($parser->getParentTag()) {
603
            case 'channel':
604
                $parser->setChannelData('lastbuilddate', $data);
605
                break;
606
            default:
607
                break;
608
        }
609
    }
610
}
611
612
/**
613
 * Class RssImageHandler
614
 */
615
class RssImageHandler extends XmlTagHandler
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
616
{
617
    /**
618
     * @return string
619
     */
620
    public function getName()
621
    {
622
        return 'image';
623
    }
624
}
625
626
/**
627
 * Class RssUrlHandler
628
 */
629
class RssUrlHandler extends XmlTagHandler
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
630
{
631
    /**
632
     * @return string
633
     */
634
    public function getName()
635
    {
636
        return 'url';
637
    }
638
639
    /**
640
     * @param XoopsXmlRss2Parser $parser parser
641
     * @param array $data
642
     * @return void
643
     */
644
    public function handleCharacterData(SaxParser $parser, &$data)
645
    {
646
        if ($parser->getParentTag() === 'image') {
647
            $parser->setImageData('url', $data);
648
        }
649
    }
650
}
651
652
/**
653
 * Class RssWidthHandler
654
 */
655
class RssWidthHandler extends XmlTagHandler
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
656
{
657
    /**
658
     * @return string
659
     */
660
    public function getName()
661
    {
662
        return 'width';
663
    }
664
665
    /**
666
     * @param XoopsXmlRss2Parser $parser parser
667
     * @param array $data
668
     * @return void
669
     */
670
    public function handleCharacterData(SaxParser $parser, &$data)
671
    {
672
        if ($parser->getParentTag() === 'image') {
673
            $parser->setImageData('width', $data);
674
        }
675
    }
676
}
677
678
/**
679
 * Class RssHeightHandler
680
 */
681
class RssHeightHandler extends XmlTagHandler
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
682
{
683
    /**
684
     * @return string
685
     */
686
    public function getName()
687
    {
688
        return 'height';
689
    }
690
691
    /**
692
     * @param XoopsXmlRss2Parser $parser parser
693
     * @param array $data
694
     * @return void
695
     */
696
    public function handleCharacterData(SaxParser $parser, &$data)
697
    {
698
        if ($parser->getParentTag() === 'image') {
699
            $parser->setImageData('height', $data);
700
        }
701
    }
702
}
703
704
/**
705
 * Class RssItemHandler
706
 */
707
class RssItemHandler extends XmlTagHandler
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
708
{
709
    /**
710
     * @return string
711
     */
712
    public function getName()
713
    {
714
        return 'item';
715
    }
716
717
    /**
718
     * @param XoopsXmlRss2Parser $parser parser
719
     * @param array              $attributes
720
     * @return void
721
     */
722
    public function handleBeginElement(SaxParser $parser, &$attributes)
723
    {
724
        $parser->resetTempArr();
725
    }
726
727
    /**
728
     * @param XoopsXmlRss2Parser $parser parser
729
     * @return void
730
     */
731
    public function handleEndElement(SaxParser $parser)
732
    {
733
        $items = $parser->getTempArr();
734
        $parser->setItems($items);
0 ignored issues
show
Bug introduced by
The method setItems() does not exist on SaxParser. It seems like you code against a sub-type of SaxParser such as XoopsXmlRss2Parser. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

734
        $parser->/** @scrutinizer ignore-call */ 
735
                 setItems($items);
Loading history...
735
    }
736
}
737
738
/**
739
 * Class RssCategoryHandler
740
 */
741
class RssCategoryHandler extends XmlTagHandler
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
742
{
743
    /**
744
     * @return string
745
     */
746
    public function getName()
747
    {
748
        return 'category';
749
    }
750
751
    /**
752
     * @param XoopsXmlRss2Parser $parser parser
753
     * @param array $data
754
     * @return void
755
     */
756
    public function handleCharacterData(SaxParser $parser, &$data)
757
    {
758
        switch ($parser->getParentTag()) {
759
            case 'channel':
760
                $parser->setChannelData('category', $data);
761
                break;
762
            case 'item':
763
                $parser->setTempArr('category', $data, ', ');
764
                break;
765
            default:
766
                break;
767
        }
768
    }
769
}
770
771
/**
772
 * Class RssCommentsHandler
773
 */
774
class RssCommentsHandler extends XmlTagHandler
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
775
{
776
    /**
777
     * @return string
778
     */
779
    public function getName()
780
    {
781
        return 'comments';
782
    }
783
784
    /**
785
     * @param XoopsXmlRss2Parser $parser parser
786
     * @param array $data
787
     * @return void
788
     */
789
    public function handleCharacterData(SaxParser $parser, &$data)
790
    {
791
        if ($parser->getParentTag() === 'item') {
792
            $parser->setTempArr('comments', $data);
793
        }
794
    }
795
}
796
797
/**
798
 * Class RssPubDateHandler
799
 */
800
class RssPubDateHandler extends XmlTagHandler
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
801
{
802
    /**
803
     * @return string
804
     */
805
    public function getName()
806
    {
807
        return 'pubDate';
808
    }
809
810
    /**
811
     * @param XoopsXmlRss2Parser $parser parser
812
     * @param array $data
813
     * @return void
814
     */
815
    public function handleCharacterData(SaxParser $parser, &$data)
816
    {
817
        switch ($parser->getParentTag()) {
818
            case 'channel':
819
                $parser->setChannelData('pubdate', $data);
820
                break;
821
            case 'item':
822
                $parser->setTempArr('pubdate', $data);
823
                break;
824
            default:
825
                break;
826
        }
827
    }
828
}
829
830
/**
831
 * Class RssGuidHandler
832
 */
833
class RssGuidHandler extends XmlTagHandler
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
834
{
835
    /**
836
     * @return string
837
     */
838
    public function getName()
839
    {
840
        return 'guid';
841
    }
842
843
    /**
844
     * @param XoopsXmlRss2Parser $parser parser
845
     * @param array $data
846
     * @return void
847
     */
848
    public function handleCharacterData(SaxParser $parser, &$data)
849
    {
850
        if ($parser->getParentTag() === 'item') {
851
            $parser->setTempArr('guid', $data);
852
        }
853
    }
854
}
855
856
/**
857
 * Class RssAuthorHandler
858
 */
859
class RssAuthorHandler extends XmlTagHandler
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
860
{
861
    /**
862
     * @return string
863
     */
864
    public function getName()
865
    {
866
        return 'author';
867
    }
868
869
    /**
870
     * @param XoopsXmlRss2Parser $parser parser
871
     * @param array $data
872
     * @return void
873
     */
874
    public function handleCharacterData(SaxParser $parser, &$data)
875
    {
876
        if ($parser->getParentTag() === 'item') {
877
            $parser->setTempArr('author', $data);
878
        }
879
    }
880
}
881
882
/**
883
 * Class RssSourceHandler
884
 */
885
class RssSourceHandler extends XmlTagHandler
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
886
{
887
    /**
888
     * @return string
889
     */
890
    public function getName()
891
    {
892
        return 'source';
893
    }
894
895
    /**
896
     * @param XoopsXmlRss2Parser $parser parser
897
     * @param array $attributes
898
     * @return void
899
     */
900
    public function handleBeginElement(SaxParser $parser, &$attributes)
901
    {
902
        if ($parser->getParentTag() === 'item') {
903
            $parser->setTempArr('source_url', $attributes['url']);
904
        }
905
    }
906
907
    /**
908
     * @param XoopsXmlRss2Parser $parser parser
909
     * @param array $data
910
     * @return void
911
     */
912
    public function handleCharacterData(SaxParser $parser, &$data)
913
    {
914
        if ($parser->getParentTag() === 'item') {
915
            $parser->setTempArr('source', $data);
916
        }
917
    }
918
}
919