b374k
m1n1 1.01
Apache/2.4.41 (Ubuntu)
Linux vmi616275.contaboserver.net 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64
uid=33(www-data) gid=33(www-data) groups=33(www-data)
server ip : 62.171.164.128 | your ip : 127.0.0.1
safemode OFF
 >  / home / a / home / dev2.destoffenstraat.com / vendor / vertex / sdk / src / Mapper / Api60 /
Filename/home/a/home/dev2.destoffenstraat.com/vendor/vertex/sdk/src/Mapper/Api60/JurisdictionMapper.php
Size4.79 kb
Permissionrw-rw-rw-
Ownerroot : root
Create time21-Aug-2025 12:26
Last modified23-Sep-2020 09:46
Last accessed11-Aug-2025 04:26
Actionsedit | rename | delete | download (gzip)
Viewtext | code | image
<?php

/**
* @copyright Vertex. All rights reserved. https://www.vertexinc.com/
* @author Mediotype Development <diveinto@mediotype.com>
*/

namespace Vertex\Mapper\Api60;

use Vertex\Data\Jurisdiction;
use Vertex\Data\JurisdictionInterface;
use Vertex\Mapper\JurisdictionMapperInterface;
use Vertex\Mapper\MapperUtilities;

/**
* API Level 60 implementation of {@see JurisdictionMapperInterface}
*/
class JurisdictionMapper implements JurisdictionMapperInterface
{
/**
* Maximum length of an external jurisdiction code
*/
const EXTERNAL_JURISDICTION_CODE_MAX = 20;

/**
* Minimum length of an external jurisdiction code
*/
const EXTERNAL_JURISDICTION_CODE_MIN = 1;

/**
* Maximim ID a Jurisdiction can have
*/
const JURISDICTION_ID_MAX = 999999999;

/**
* Minimum ID a Jurisdiction can have
*/
const JURISDICTION_ID_MIN = 0;

/** @var MapperUtilities */
private $utilities;

/**
* @param MapperUtilities|null $utilities
*/
public function __construct(MapperUtilities $utilities = null)
{
$this->utilities = $utilities ?: new MapperUtilities();
}

/**
* @inheritdoc
*/
public function build(\stdClass $map)
{
$jurisdiction = new Jurisdiction();
if (isset($map->jurisdictionLevel)) {
$jurisdiction->setLevel($map->jurisdictionLevel);
}
if (isset($map->jurisdictionId)) {
$jurisdiction->setId($map->jurisdictionId);
}
if (isset($map->effectiveDate)) {
$jurisdiction->setEffectiveDate(new \DateTime($map->effectiveDate));
}
if (isset($map->expirationDate)) {
$jurisdiction->setExpirationDate(new \DateTime($map->expirationDate));
}
if (isset($map->externalJurisdictionCode)) {
$jurisdiction->setExternalJurisdictionCode($map->externalJurisdictionCode);
}
if (isset($map->_)) {
$jurisdiction->setName($map->_);
}

return $jurisdiction;
}

/**
* @inheritdoc
*/
public function map(JurisdictionInterface $object)
{
$map = new \stdClass();
$map = $this->utilities->addToMapWithEnumerationValidation(
$map,
$object->getLevel(),
'jurisdictionLevel',
[
JurisdictionInterface::JURISDICTION_LEVEL_APO,
JurisdictionInterface::JURISDICTION_LEVEL_BOROUGH,
JurisdictionInterface::JURISDICTION_LEVEL_CITY,
JurisdictionInterface::JURISDICTION_LEVEL_COUNTRY,
JurisdictionInterface::JURISDICTION_LEVEL_COUNTY,
JurisdictionInterface::JURISDICTION_LEVEL_DISTRICT,
JurisdictionInterface::JURISDICTION_LEVEL_FPO,
JurisdictionInterface::JURISDICTION_LEVEL_LOCAL_IMPROVEMENT_DISTRICT,
JurisdictionInterface::JURISDICTION_LEVEL_PARISH,
JurisdictionInterface::JURISDICTION_LEVEL_PROVINCE,
JurisdictionInterface::JURISDICTION_LEVEL_SPECIAL_PURPOSE_DISTRICT,
JurisdictionInterface::JURISDICTION_LEVEL_STATE,
JurisdictionInterface::JURISDICTION_LEVEL_TERRITORY,
JurisdictionInterface::JURISDICTION_LEVEL_TOWNSHIP,
JurisdictionInterface::JURISDICTION_LEVEL_TRADE_BLOCK,
JurisdictionInterface::JURISDICTION_LEVEL_TRANSIT_DISTRICT
],
false,
'Jurisdiction level'
);
$map = $this->utilities->addToMapWithIntegerValidation(
$map,
$object->getId(),
'jurisdictionId',
static::JURISDICTION_ID_MIN,
static::JURISDICTION_ID_MAX,
false,
'Jurisdiction ID'
);
$map = $this->utilities->addToMapWithDateValidation(
$map,
$object->getEffectiveDate(),
'effectiveDate',
true,
'Effective Date'
);
$map = $this->utilities->addToMapWithDateValidation(
$map,
$object->getExpirationDate(),
'expirationDate',
true,
'Expiration Date'
);
$map = $this->utilities->addToMapWithLengthValidation(
$map,
$object->getExternalJurisdictionCode(),
'externalJurisdictionCode',
static::EXTERNAL_JURISDICTION_CODE_MIN,
static::EXTERNAL_JURISDICTION_CODE_MAX,
true,
'External Jurisdiction Code'
);
$map = $this->utilities->addToMapWithLengthValidation(
$map,
$object->getName(),
'_',
MapperUtilities::DEFAULT_MIN,
MapperUtilities::DEFAULT_MAX,
true,
'Name'
);

return $map;
}
}