Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit d3ce672

Browse files
committed
chore: changed constant names
1 parent e99c995 commit d3ce672

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/Rule/Country.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88

99
class Country extends AbstractRule implements RuleInterface
1010
{
11-
public const ALPHA2_CODE = 'alpha2';
12-
public const ALPHA3_CODE = 'alpha3';
11+
public const ALPHA_2_CODE = 'alpha-2';
12+
public const ALPHA_3_CODE = 'alpha-3';
1313

1414
private const CODE_OPTIONS = [
15-
self::ALPHA2_CODE,
16-
self::ALPHA3_CODE
15+
self::ALPHA_2_CODE,
16+
self::ALPHA_3_CODE
1717
];
1818

1919
public function __construct(
20-
private readonly string $code = self::ALPHA2_CODE,
20+
private readonly string $code = self::ALPHA_2_CODE,
2121
private readonly string $message = 'The "{{ name }}" value is not a valid country code, "{{ value }}" given.'
2222
) {}
2323

@@ -43,8 +43,8 @@ public function assert(mixed $value, string $name): void
4343
$input = strtoupper($value);
4444

4545
if (
46-
($this->code === self::ALPHA2_CODE && !Countries::exists($input))
47-
|| ($this->code === self::ALPHA3_CODE && !Countries::alpha3CodeExists($input))
46+
($this->code === self::ALPHA_2_CODE && !Countries::exists($input))
47+
|| ($this->code === self::ALPHA_3_CODE && !Countries::alpha3CodeExists($input))
4848
) {
4949
throw new CountryException(
5050
message: $this->message,

tests/CountryTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@ public static function provideRuleFailureConditionData(): \Generator
3131
$message = '/The "(.*)" value is not a valid country code, "(.*)" given./';
3232

3333
yield 'default' => [new Country(), 'PRT', $exception, $message];
34-
yield 'alpha2' => [new Country(code: 'alpha2'), 'PRT', $exception, $message];
35-
yield 'alpha3' => [new Country(code: 'alpha3'), 'PT', $exception, $message];
34+
yield 'alpha2' => [new Country(code: 'alpha-2'), 'PRT', $exception, $message];
35+
yield 'alpha3' => [new Country(code: 'alpha-3'), 'PT', $exception, $message];
3636
}
3737

3838
public static function provideRuleSuccessConditionData(): \Generator
3939
{
4040
yield 'default' => [new Country(), 'PT'];
41-
yield 'alpha2' => [new Country(code: 'alpha2'), 'PT'];
42-
yield 'alpha2 lowercase' => [new Country(code: 'alpha2'), 'pt'];
43-
yield 'alpha3' => [new Country(code: 'alpha3'), 'PRT'];
44-
yield 'alpha3 lowercase' => [new Country(code: 'alpha3'), 'prt'];
41+
yield 'alpha2' => [new Country(code: 'alpha-2'), 'PT'];
42+
yield 'alpha2 lowercase' => [new Country(code: 'alpha-2'), 'pt'];
43+
yield 'alpha3' => [new Country(code: 'alpha-3'), 'PRT'];
44+
yield 'alpha3 lowercase' => [new Country(code: 'alpha-3'), 'prt'];
4545
}
4646

4747
public static function provideRuleMessageOptionData(): \Generator
@@ -51,7 +51,7 @@ public static function provideRuleMessageOptionData(): \Generator
5151
message: 'The "{{ name }}" value "{{ value }}" is not a valid "{{ code }}" country code.'
5252
),
5353
'invalid',
54-
'The "test" value "invalid" is not a valid "alpha2" country code.'
54+
'The "test" value "invalid" is not a valid "alpha-2" country code.'
5555
];
5656
}
5757
}

0 commit comments

Comments
 (0)