Skip to content

Commit

Permalink
Added interior measurements elements handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanruzak committed Jan 4, 2024
1 parent 1f38196 commit 6de1868
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/AdType.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use eiriksm\FinnTransfer\Traits\ContactTrait;
use eiriksm\FinnTransfer\Traits\EngineTrait;
use eiriksm\FinnTransfer\Traits\HeaderTrait;
use eiriksm\FinnTransfer\Traits\InteriorMeasurementsTrait;
use eiriksm\FinnTransfer\Traits\MoreInfoTrait;
use eiriksm\FinnTransfer\Traits\MotorPriceTrait;
use eiriksm\FinnTransfer\Traits\ObjectTrait;
Expand All @@ -13,6 +14,7 @@ abstract class AdType extends XmlBase implements AdTypeInterface
{
use MotorPriceTrait;
use EngineTrait;
use InteriorMeasurementsTrait;
use MoreInfoTrait;
use ContactTrait;
use HeaderTrait;
Expand Down
2 changes: 1 addition & 1 deletion src/AdTypes/BusXml.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct($partner_id, $provider)
$this->CHASSIS_NO = '';
$this->BOX_TYPE = '';
$this->BOX_LENGTH = '';
$this->INTERIOR_MEASUREMENTS = '';
$this->createInteriorMeasurementsElements();
$this->TAILLIFT = '';
$this->DESCRIPTION = '';
$this->createMoreInfoElements();
Expand Down
2 changes: 1 addition & 1 deletion src/AdTypes/VanTruckXml.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct($partner_id, $provider)
$this->CHASSIS_NO = '';
$this->BOX_TYPE = '';
$this->BOX_LENGTH = '';
$this->INTERIOR_MEASUREMENTS = '';
$this->createInteriorMeasurementsElements();
$this->TAILLIFT = '';
$this->DESCRIPTION = '';
$this->createMoreInfoElements();
Expand Down
61 changes: 61 additions & 0 deletions src/Traits/InteriorMeasurementsTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

namespace eiriksm\FinnTransfer\Traits;

trait InteriorMeasurementsTrait
{

/**
* @var \DOMElement
*/
protected $interiorMeasurementsBody;

/**
* @var \DOMElement
*/
protected $interiorMeasurementsLengthBody;

/**
* @var \DOMElement
*/
protected $interiorMeasurementsWidthBody;

/**
* @var \DOMElement
*/
protected $interiorMeasurementsHeightBody;

public function setInteriorMeasurements()
{
if (!isset($this->interiorMeasurementsBody)) {
$this->createInteriorMeasurementsElements();
}
}

protected function createInteriorMeasurementsElements()
{
$this->interiorMeasurementsBody = $this->dom->createElement('INTERIOR_MEASUREMENTS');
$this->interiorMeasurementsLengthBody = $this->dom->createElement('LENGTH');
$this->interiorMeasurementsWidthBody = $this->dom->createElement('WIDTH');
$this->interiorMeasurementsHeightBody = $this->dom->createElement('HEIGHT');
$this->interiorMeasurementsBody->appendChild($this->interiorMeasurementsHeightBody);
$this->interiorMeasurementsBody->appendChild($this->interiorMeasurementsWidthBody);
$this->interiorMeasurementsBody->appendChild($this->interiorMeasurementsLengthBody);
$this->adBody->appendChild($this->interiorMeasurementsBody);
}

public function setInteriorMeasurementsLength($length)
{
$this->interiorMeasurementsLengthBody->nodeValue = $length;
}

public function setInteriorMeasurementsWidth($width)
{
$this->interiorMeasurementsWidthBody->nodeValue = $width;
}

public function setInteriorMeasurementsHeight($height)
{
$this->interiorMeasurementsHeightBody->nodeValue = $height;
}
}

0 comments on commit 6de1868

Please sign in to comment.