-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
00d1216
commit 3610c4c
Showing
16 changed files
with
632 additions
and
456 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/vendor | ||
*.cache | ||
/composer.lock | ||
/.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
namespace Yahooauc; | ||
|
||
use SimpleXMLElement; | ||
|
||
class AuctionXml | ||
{ | ||
private $html; | ||
private $xml; | ||
|
||
public function __construct($body) | ||
{ | ||
$this->html = Parser::getHtmlDom($body); | ||
$this->xml = new SimpleXMLElement('<ResultSet><Result></Result></ResultSet>'); | ||
|
||
$this->addTitle(); | ||
$this->addSellerId(); | ||
$this->addImagesUrl(); | ||
$this->addPrice(); | ||
$this->addDetail(); | ||
$this->addStatus(); | ||
} | ||
|
||
public function setAuctionId($auctionId) | ||
{ | ||
$this->xml->Result->AuctionID = $auctionId; | ||
} | ||
|
||
public function setAuctionUrl($url) | ||
{ | ||
$this->xml->Result->AuctionItemUrl = $url; | ||
} | ||
|
||
public function getXml() | ||
{ | ||
return $this->xml; | ||
} | ||
|
||
private function addTitle() | ||
{ | ||
$this->xml->Result->Title = Parser::getAuctionTitle($this->html); | ||
} | ||
|
||
private function addSellerId() | ||
{ | ||
$this->xml->Result->Seller->Id = Parser::getAuctionSellerId($this->html); | ||
} | ||
|
||
public function addImagesUrl() | ||
{ | ||
$this->xml->Result->addChild('Img'); | ||
|
||
foreach (Parser::getAuctionImagesUrl($this->html) as $key => $url) { | ||
$childName = 'Image'.++$key; | ||
$this->xml->Result->Img->$childName = $url; | ||
} | ||
} | ||
|
||
public function addPrice() | ||
{ | ||
$data = Parser::getAuctionPrice($this->html); | ||
|
||
$this->xml->Result->Price = $data['price']; | ||
$this->xml->Result->TaxinPrice = ($data['taxPrice'] > 0) ? $data['taxPrice'] : $data['price']; | ||
} | ||
|
||
public function addDetail() | ||
{ | ||
$data = Parser::getAuctionDetail($this->html); | ||
|
||
$this->xml->Result->StartTime = $data['start']; | ||
$this->xml->Result->EndTime = $data['end']; | ||
} | ||
|
||
private function addStatus() | ||
{ | ||
$this->xml->Result->Status = Parser::getAuctionStatus($this->html); | ||
} | ||
} |
Oops, something went wrong.