Passed
Push — trunk ( c1976e...a42427 )
by Christian
12:40 queued 13s
created

CustomerZipCode::getMessageRequired()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
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 Symfony\Component\Validator\Constraint;
6
use Symfony\Component\Validator\Constraints\NotBlank;
7
8
/**
9
 * @Annotation
10
 * @Target({"PROPERTY", "METHOD", "ANNOTATION"})
11
 */
12
class CustomerZipCode extends Constraint
13
{
14
    public const ZIP_CODE_INVALID = 'ZIP_CODE_INVALID';
15
16
    public ?string $countryId = null;
17
18
    public bool $caseSensitiveCheck = true;
19
20
    /**
21
     * @var array<string, string>
22
     */
23
    protected static $errorNames = [
24
        NotBlank::IS_BLANK_ERROR => 'IS_BLANK_ERROR',
25
        self::ZIP_CODE_INVALID => 'ZIP_CODE_INVALID',
26
    ];
27
28
    private string $message = 'This value is not a valid ZIP code for country {{ iso }}';
29
30
    private string $messageRequired = 'Postal code is required for that country';
31
32
    /**
33
     * @param mixed $options
34
     */
35
    public function __construct($options = null)
36
    {
37
        if ($options !== null && !\is_array($options)) {
38
            $options = [
39
                'countryId' => $options,
40
            ];
41
        }
42
43
        parent::__construct($options);
44
    }
45
46
    public function getMessageRequired(): string
47
    {
48
        return $this->messageRequired;
49
    }
50
51
    public function getMessage(): string
52
    {
53
        return $this->message;
54
    }
55
}
56