From 43a065ac0c7df7ea3e25746e6baa7815f111483e Mon Sep 17 00:00:00 2001 From: jetwitaussi Date: Fri, 19 Jun 2020 17:53:48 +0200 Subject: [PATCH] Fix regions chunk --- PHT/Xml/World/Country.php | 4 ++-- PHT/Xml/World/Region/Chunk.php | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/PHT/Xml/World/Country.php b/PHT/Xml/World/Country.php index b24a4c2..18d17f5 100644 --- a/PHT/Xml/World/Country.php +++ b/PHT/Xml/World/Country.php @@ -356,7 +356,7 @@ public function getRegionsNumber() * Return region object * * @param integer $index - * @return \PHT\Xml\World\Region + * @return \PHT\Xml\World\Region\Chunk */ public function getRegion($index) { @@ -374,7 +374,7 @@ public function getRegion($index) /** * Return iterator of regions objects * - * @return \PHT\Xml\World\Region[] + * @return \PHT\Xml\World\Region\Chunk[] */ public function getRegions() { diff --git a/PHT/Xml/World/Region/Chunk.php b/PHT/Xml/World/Region/Chunk.php index 7b92f22..f310a0e 100644 --- a/PHT/Xml/World/Region/Chunk.php +++ b/PHT/Xml/World/Region/Chunk.php @@ -14,8 +14,9 @@ namespace PHT\Xml\World\Region; use PHT\Xml; +use PHT\Wrapper; -class Chunk extends Xml\World\Region +class Chunk extends Xml\Base { /** * @param \DOMDocument $xml @@ -25,4 +26,34 @@ public function __construct($xml) $this->xmlText = $xml->saveXML(); $this->xml = $xml; } + + /** + * Return region id + * + * @return integer + */ + public function getId() + { + return $this->getXml()->getElementsByTagName('RegionID')->item(0)->nodeValue; + } + + /** + * Return region id + * + * @return integer + */ + public function getName() + { + return $this->getXml()->getElementsByTagName('RegionName')->item(0)->nodeValue; + } + + /** + * Get full region details + * + * @return Xml\World\Region + */ + public function getRegion() + { + return Wrapper\World::region($this->getId()); + } }