00001 <?php 00002 00006 class oxCompanyVatInValidator 00007 { 00008 00012 private $_oCountry = null; 00013 00019 private $_aCheckers = array(); 00020 00026 private $_sError = ''; 00027 00033 public function setCountry(oxCountry $oCountry) 00034 { 00035 $this->_oCountry = $oCountry; 00036 } 00037 00043 public function getCountry() 00044 { 00045 return $this->_oCountry; 00046 } 00047 00053 public function setError($sError) 00054 { 00055 $this->_sError = $sError; 00056 } 00057 00063 public function getError() 00064 { 00065 return $this->_sError; 00066 } 00067 00073 public function __construct(oxCountry $oCountry) 00074 { 00075 $this->setCountry($oCountry); 00076 } 00077 00083 public function addChecker(oxCompanyVatInChecker $oValidator) 00084 { 00085 $this->_aCheckers[] = $oValidator; 00086 } 00087 00093 public function getCheckers() 00094 { 00095 return $this->_aCheckers; 00096 } 00097 00105 public function validate(oxCompanyVatIn $oCompanyVatNumber) 00106 { 00107 $blResult = false; 00108 $aValidators = $this->getCheckers(); 00109 00110 foreach ($aValidators as $oValidator) { 00111 $blResult = true; 00112 if ($oValidator instanceof oxICountryAware) { 00113 $oValidator->setCountry($this->getCountry()); 00114 } 00115 00116 if (!$oValidator->validate($oCompanyVatNumber)) { 00117 $blResult = false; 00118 $this->setError($oValidator->getError()); 00119 break; 00120 } 00121 } 00122 00123 return $blResult; 00124 } 00125 }