Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getVatPattern example
return
;
}
if
(
!
is_iterable
(
$vatIds
)
)
{
throw
new
UnexpectedValueException
(
$vatIds
, 'iterable'
)
;
}
if
(
!
$this
->
shouldCheckVatIdFormat
(
$constraint
)
)
{
return
;
}
if
(
!
$vatPattern
=
$this
->
getVatPattern
(
$constraint
)
)
{
return
;
}
$regex
= '/^' .
$vatPattern
. '$/i';
foreach
(
$vatIds
as
$vatId
)
{
if
(
!
preg_match
(
$regex
,
(string)
$vatId
)
)
{
$this
->context->
buildViolation
(
$constraint
->message
)
->
setParameter
(
'{{ vatId }}',
$this
->
formatValue
(
$vatId
)
)
->
setCode
(
CustomerVatIdentification::VAT_ID_FORMAT_NOT_CORRECT
)
->
addViolation
(
)
;
}