Улучшен trait HasInn

* Constraints::PATTERN_INN
* phpdoc
pull/2/head
Anthony Axenov 2020-06-07 19:26:33 +08:00
parent 1061914a5f
commit b74f652127
1 changed files with 3 additions and 2 deletions

View File

@ -9,6 +9,7 @@
namespace AtolOnline\Traits;
use AtolOnline\Constants\Constraints;
use AtolOnline\Exceptions\AtolInnWrongLengthException;
/**
@ -39,12 +40,12 @@ trait HasInn
*
* @param string $inn
* @return $this
* @throws AtolInnWrongLengthException
* @throws AtolInnWrongLengthException Некорректная длина ИНН
*/
public function setInn(string $inn)
{
$inn = preg_replace("/[^0-9]/", '', $inn);
if (preg_match_all("/(^[0-9]{10}$)|(^[0-9]{12}$)/", $inn) == 0) {
if (preg_match_all(Constraints::PATTERN_INN, $inn) == 0) {
throw new AtolInnWrongLengthException($inn);
}
$this->inn = $inn;