1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @package domain |
4
|
|
|
* @subpackage models |
5
|
|
|
* @author marius orcsik <[email protected]> |
6
|
|
|
* @date 2010.04.13 |
7
|
|
|
*/ |
8
|
|
|
namespace vsc\domain\models; |
9
|
|
|
|
10
|
|
|
use vsc\domain\domain\RssItem; |
11
|
|
|
use vsc\infrastructure\Base; |
12
|
|
|
use vsc\ExceptionUnimplemented; |
13
|
|
|
|
14
|
|
|
class RssReader extends XmlReader { |
15
|
|
|
public $title; |
16
|
|
|
public $link; |
17
|
|
|
public $description; |
18
|
|
|
public $generator; |
19
|
|
|
public $docs; |
20
|
|
|
public $language; |
21
|
|
|
public $pubDate; |
22
|
|
|
public $lastBuildDate; |
23
|
|
|
private $items = array(); |
24
|
|
|
|
25
|
1 |
|
public function getItems() { |
26
|
1 |
|
return $this->items; |
27
|
|
|
} |
28
|
|
|
|
29
|
1 |
|
public function setItems($aItems) { |
30
|
1 |
|
$this->items = $aItems; |
31
|
1 |
|
} |
32
|
|
|
|
33
|
1 |
|
public function addItem(RssItem $oElement) { |
34
|
1 |
|
$this->items[] = $oElement; |
35
|
1 |
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @param integer $iIndex |
39
|
|
|
* @return Base |
40
|
|
|
*/ |
41
|
1 |
|
public function getItem($iIndex) { |
42
|
1 |
|
if (isset ($this->items[$iIndex])) { |
43
|
|
|
return $this->items[$iIndex]; |
44
|
|
|
} else { |
45
|
1 |
|
return new Base(); |
46
|
|
|
} |
47
|
|
|
} |
48
|
|
|
|
49
|
1 |
|
public function buildObj() { |
50
|
1 |
|
parent::buildObj(); |
51
|
|
|
|
52
|
1 |
|
$oNode = $this->getDom()->getElementsByTagName('channel')->item(0); |
53
|
1 |
|
if ($oNode instanceof \DOMElement) { |
54
|
|
|
$this->parseToEntity($oNode->childNodes); |
55
|
|
|
} |
56
|
1 |
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @param \DOMNodeList $aChildNodes |
60
|
|
|
*/ |
61
|
1 |
|
public function parseToEntity($aChildNodes) { |
62
|
1 |
|
if ($aChildNodes instanceof \DOMNodeList) { |
63
|
1 |
|
foreach ($aChildNodes as $oChildNode) { |
64
|
|
|
$sNodeName = $oChildNode->nodeName; |
65
|
|
|
if ($oChildNode->nodeType == XML_ELEMENT_NODE) { |
66
|
|
|
if ($sNodeName == 'item') { |
67
|
|
|
$oRssItem = new RssItem($oChildNode); |
68
|
|
|
$this->addItem($oRssItem); |
69
|
|
|
} elseif ($this->valid($sNodeName)) { |
|
|
|
|
70
|
|
|
try { |
71
|
|
|
$this->$sNodeName = $oChildNode->nodeValue; |
72
|
|
|
} catch (ExceptionUnimplemented $e) { |
|
|
|
|
73
|
|
|
// the property didn't exist |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
} |
79
|
1 |
|
} |
80
|
|
|
} |
81
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.