Skip to content

Commit dc1012b

Browse files
Countries::isCountryCodeInEU(string ) should return false after Brexit transition period ends on Dec 31, 2020
1 parent bf3dcf2 commit dc1012b

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/Countries.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
namespace Ibericode\Vat;
55

6+
use DateTime;
7+
68
/**
79
* Class Countries
810
*
@@ -279,7 +281,12 @@ public function hasCountryCode(string $code) : bool
279281
public function isCountryCodeInEU(string $code) : bool
280282
{
281283
$eu = ['AT', 'BE', 'BG', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HU', 'HR', 'IE', 'IT', 'LT', 'LU', 'LV', 'MT', 'NL', 'PL', 'PT', 'RO', 'SE', 'SI', 'SK'];
282-
return in_array($code, $eu);
284+
285+
// Brexit transition period ends on Dec 31 23:59, so this method should return true only until then
286+
if ((new DateTime('now')) < (new DateTime('2021-01-01 00:00:00'))) {
287+
$eu[] = 'GB';
288+
}
289+
return in_array($code, $eu, true);
283290
}
284291

285292

tests/CountriesTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Ibericode\Vat\Tests;
44

5+
use DateTime;
56
use Ibericode\Vat\Countries;
67
use Ibericode\Vat\Exception;
78
use PHPUnit\Framework\TestCase;
@@ -60,5 +61,14 @@ public function testIsCodeInEU()
6061
$this->assertFalse($countries->isCountryCodeInEU('FOO'));
6162
$this->assertFalse($countries->isCountryCodeInEU('US'));
6263
$this->assertTrue($countries->isCountryCodeInEU('NL'));
64+
65+
// test for Brexit
66+
$now = new DateTime('now');
67+
$y2021 = new DateTime('2021-01-01 00:00:00');
68+
if ($now > $y2021) {
69+
$this->assertFalse($countries->isCountryCodeInEU('GB'));
70+
} else {
71+
$this->assertTrue($countries->isCountryCodeInEU('GB'));
72+
}
6373
}
6474
}

0 commit comments

Comments
 (0)