Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interior measurements elements handling #16

Merged
merged 3 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/AdTypes/BusXml.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
namespace eiriksm\FinnTransfer\AdTypes;

use eiriksm\FinnTransfer\AdType;
use eiriksm\FinnTransfer\Traits\InteriorMeasurementsTrait;
use eiriksm\FinnTransfer\Traits\ModelPropertyTrait;

class BusXml extends AdType
{

use ModelPropertyTrait;
use InteriorMeasurementsTrait;

protected $dtd = 'http://www.iad.no/dtd/IADIF-bus1.dtd';

Expand Down Expand Up @@ -44,7 +46,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
4 changes: 3 additions & 1 deletion src/AdTypes/VanTruckXml.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
namespace eiriksm\FinnTransfer\AdTypes;

use eiriksm\FinnTransfer\AdType;
use eiriksm\FinnTransfer\Traits\InteriorMeasurementsTrait;
use eiriksm\FinnTransfer\Traits\ModelPropertyTrait;

class VanTruckXml extends AdType
{

use ModelPropertyTrait;
use InteriorMeasurementsTrait;

protected $dtd = 'http://www.iad.no/dtd/IADIF-van-truck-10.dtd';

Expand Down Expand Up @@ -44,7 +46,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
65 changes: 65 additions & 0 deletions src/Traits/InteriorMeasurementsTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

namespace eiriksm\FinnTransfer\Traits;

trait InteriorMeasurementsTrait
{

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

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

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

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

protected function createInteriorMeasurementsElements()
{
if (!isset($this->interiorMeasurementsBody)) {
$this->interiorMeasurementsBody = $this->dom->createElement('INTERIOR_MEASUREMENTS');

$this->interiorMeasurementsLengthBody = $this->dom->createElement('LENGTH');
$this->interiorMeasurementsBody->appendChild($this->interiorMeasurementsLengthBody);

$this->interiorMeasurementsWidthBody = $this->dom->createElement('WIDTH');
$this->interiorMeasurementsBody->appendChild($this->interiorMeasurementsWidthBody);

$this->interiorMeasurementsHeightBody = $this->dom->createElement('HEIGHT');
$this->interiorMeasurementsBody->appendChild($this->interiorMeasurementsHeightBody);

$this->adBody->appendChild($this->interiorMeasurementsBody);
}
}

public function setInteriorMeasurements()
{
$this->createInteriorMeasurementsElements();
}

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

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

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