parent
2750443612
commit
29ea8882fe
@ -29,6 +29,8 @@ class Deal
|
||||
protected $image1;
|
||||
/** @var string */
|
||||
protected $image2;
|
||||
/** @var \DateTime */
|
||||
protected $datecreation;
|
||||
|
||||
/**
|
||||
* Deal constructor.
|
||||
@ -50,6 +52,13 @@ class Deal
|
||||
$deal->setType(self::TYPE_OFFER);
|
||||
$deal->setBody($crawler->filter('.properties_description')->first()->filter('p')->eq(1)->text());
|
||||
$deal->setPrice($crawler->filter('[itemprop=price]')->first()->attr('content'));
|
||||
$date_node = $crawler->filter('[itemprop=availabilityStarts]')->first();
|
||||
$date = \DateTime::createFromFormat('Y-m-d', $date_node->attr('content'));
|
||||
$hours = current($date_node->extract(['_text']));
|
||||
$hours = substr($hours, strpos($hours, 'à')+2);
|
||||
list($hour, $min) = explode(':', $hours);
|
||||
$date->setTime((int) $hour, (int) $min);
|
||||
$deal->setDateCreation($date);
|
||||
if ($crawler->filter('.item_photo')->count() > 0) {
|
||||
$script = $crawler ->filter('.item_photo')->first()->nextAll()
|
||||
->filter('script')->first()->html();
|
||||
@ -236,6 +245,24 @@ class Deal
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getDateCreation()
|
||||
{
|
||||
return $this->datecreation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $price
|
||||
* @return Deal
|
||||
*/
|
||||
public function setDateCreation($datecreation)
|
||||
{
|
||||
$this->datecreation = $datecreation;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Account
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user