Passed
Push — master ( 94c447...6b7cc3 )
by Christian
11:16 queued 12s
created

CustomerVatIdentification::getCountryId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php declare(strict_types=1);
2
3
namespace Shopware\Core\Checkout\Customer\Validation\Constraint;
4
5
use Shopware\Core\Framework\Context;
6
use Symfony\Component\Validator\Constraint;
7
use Symfony\Component\Validator\Exception\MissingOptionsException;
8
9
/**
10
 * @Annotation
11
 * @Target({"PROPERTY", "METHOD", "ANNOTATION"})
12
 */
13
class CustomerVatIdentification extends Constraint
14
{
15
    public const VAT_ID_FORMAT_NOT_CORRECT = '463d3548-1caf-11eb-adc1-0242ac120002';
16
17
    /**
18
     * @var string
19
     */
20
    public $message = 'The format of vatId {{ vatId }} is not correct.';
21
22
    /**
23
     * @var bool
24
     */
25
    public $shouldCheck = true;
26
27
    /**
28
     * @var Context
29
     */
30
    public $context;
31
32
    /**
33
     * @var string
34
     */
35
    protected $countryId;
36
37
    /**
38
     * @var array
39
     */
40
    protected static $errorNames = [
41
        self::VAT_ID_FORMAT_NOT_CORRECT => 'VAT_ID_FORMAT_NOT_CORRECT',
42
    ];
43
44
    public function __construct($options = null)
45
    {
46
        parent::__construct($options);
47
48
        if ($this->countryId === null) {
49
            throw new MissingOptionsException(sprintf('Option "countryId" must be given for constraint %s', self::class), ['countryId']);
50
        }
51
    }
52
53
    public function getCountryId(): string
54
    {
55
        return $this->countryId;
56
    }
57
58
    public function getShouldCheck(): bool
59
    {
60
        return $this->shouldCheck;
61
    }
62
}
63