mirror of
https://github.com/anthonyaxenov/atol-online.git
synced 2024-11-22 16:14:34 +00:00
Улучшен trait HasInn
* Constraints::PATTERN_INN * phpdoc
This commit is contained in:
parent
1061914a5f
commit
b74f652127
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
namespace AtolOnline\Traits;
|
namespace AtolOnline\Traits;
|
||||||
|
|
||||||
|
use AtolOnline\Constants\Constraints;
|
||||||
use AtolOnline\Exceptions\AtolInnWrongLengthException;
|
use AtolOnline\Exceptions\AtolInnWrongLengthException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -39,12 +40,12 @@ trait HasInn
|
|||||||
*
|
*
|
||||||
* @param string $inn
|
* @param string $inn
|
||||||
* @return $this
|
* @return $this
|
||||||
* @throws AtolInnWrongLengthException
|
* @throws AtolInnWrongLengthException Некорректная длина ИНН
|
||||||
*/
|
*/
|
||||||
public function setInn(string $inn)
|
public function setInn(string $inn)
|
||||||
{
|
{
|
||||||
$inn = preg_replace("/[^0-9]/", '', $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);
|
throw new AtolInnWrongLengthException($inn);
|
||||||
}
|
}
|
||||||
$this->inn = $inn;
|
$this->inn = $inn;
|
||||||
|
Loading…
Reference in New Issue
Block a user