Some refactoring

This commit is contained in:
Yusuf Kandemir 2018-11-11 23:18:13 +03:00
parent 87dd20f753
commit ee7eaf1317

View File

@ -7,12 +7,8 @@ class MicrodataDOMElement extends \DOMElement
public function getProperties() public function getProperties()
{ {
$results = []; $results = [];
$memory = []; $memory = [$this];
$pending = []; $pending = $this->getChildElementNodes();
$memory[] = $this;
$pending = array_merge($pending, $this->getChildElementNodes());
if ($this->hasAttribute('itemref')) { if ($this->hasAttribute('itemref')) {
$tokens = $this->tokenizeAttribute('itemref'); $tokens = $this->tokenizeAttribute('itemref');
@ -37,7 +33,7 @@ class MicrodataDOMElement extends \DOMElement
$pending = array_merge($pending, $current->getChildElementNodes()); $pending = array_merge($pending, $current->getChildElementNodes());
} }
if ($current->hasAttribute('itemprop') && /* hasPropertyNames */ $current->getPropertyNames()) { if ($current->hasAttribute('itemprop') && $current->hasPropertyNames()) {
$results[] = $current; $results[] = $current;
} }
} }
@ -45,6 +41,10 @@ class MicrodataDOMElement extends \DOMElement
return array_reverse($results); return array_reverse($results);
} }
public function hasPropertyNames() {
return !empty($this->tokenizeAttribute('itemprop'));
}
public function getPropertyNames() public function getPropertyNames()
{ {
$tokens = $this->tokenizeAttribute('itemprop'); $tokens = $this->tokenizeAttribute('itemprop');