OXID eShop CE  4.9.7
 All Classes Files Functions Variables Pages
oxcompanyvatinvalidator.php
Go to the documentation of this file.
1 <?php
2 
7 {
8 
12  private $_oCountry = null;
13 
19  private $_aCheckers = array();
20 
26  private $_sError = '';
27 
33  public function setCountry(oxCountry $oCountry)
34  {
35  $this->_oCountry = $oCountry;
36  }
37 
43  public function getCountry()
44  {
45  return $this->_oCountry;
46  }
47 
53  public function setError($sError)
54  {
55  $this->_sError = $sError;
56  }
57 
63  public function getError()
64  {
65  return $this->_sError;
66  }
67 
73  public function __construct(oxCountry $oCountry)
74  {
75  $this->setCountry($oCountry);
76  }
77 
83  public function addChecker(oxCompanyVatInChecker $oValidator)
84  {
85  $this->_aCheckers[] = $oValidator;
86  }
87 
93  public function getCheckers()
94  {
95  return $this->_aCheckers;
96  }
97 
105  public function validate(oxCompanyVatIn $oCompanyVatNumber)
106  {
107  $blResult = false;
108  $aValidators = $this->getCheckers();
109 
110  foreach ($aValidators as $oValidator) {
111  $blResult = true;
112  if ($oValidator instanceof oxICountryAware) {
113  $oValidator->setCountry($this->getCountry());
114  }
115 
116  if (!$oValidator->validate($oCompanyVatNumber)) {
117  $blResult = false;
118  $this->setError($oValidator->getError());
119  break;
120  }
121  }
122 
123  return $blResult;
124  }
125 }