<?php
 namespace Modules\RemoteData\EntityManagementWs\Model\Entity\City; class Matching extends \Modules\RemoteData\EntityManagementWs\Model\Entity\MatchingAbstract { protected $forcedRequestAttributes = ['externalSystem', 'name', 'code', 'stationCode', 'countryCode']; protected function checkRequestData() :void { if (!$this->request->externalSystem and !$this->request->name and !$this->request->code and !$this->request->stationCode) { throw new \Modules\RemoteData\EntityManagementWs\Model\RuntimeException('At least one criteria for matching must be set.', 'CityMatchCriteriaMissing'); } if ($this->request->name and mb_strlen($this->request->name) < 2) { throw new \Modules\RemoteData\EntityManagementWs\Model\RuntimeException('The alias value must have at least 2 characters.', 'CityMatchNameMinLength'); } if ($this->request->countryCode and mb_strlen($this->request->countryCode) != 2) { throw new \Modules\RemoteData\EntityManagementWs\Model\RuntimeException('The country code must use the ISO 2 chars code.', 'CityMatchCountryCodeInvalidLength'); } } protected function getEntityMatchObj() :\App\EntityMatch\BaseAbstract { $cityMatchObj = new \App\ImportedOrder\EntityMatch\City('intersect'); if ($this->request->externalSystem) { $cityMatchObj->setIdInExtSys($this->request->externalSystem->idEntityExtSys, $this->request->externalSystem->idSystem); } if ($this->request->name) { $cityMatchObj->setName($this->request->name); } if ($this->request->code) { $cityMatchObj->setCode3($this->request->code); } if ($this->request->stationCode) { $cityMatchObj->setStationCode($this->request->stationCode); } if ($this->request->countryCode) { $cityMatchObj->filterByCountryCode($this->request->countryCode); } return $cityMatchObj; } } 