diff --git a/src/CompanyRegistrationNumber.php b/src/CompanyRegistrationNumber.php index d1f8d40..5597b6b 100644 --- a/src/CompanyRegistrationNumber.php +++ b/src/CompanyRegistrationNumber.php @@ -51,9 +51,32 @@ private function isValid( $this->isValidNL($value) || $this->isValidPT($value) || $this->isValidLU($value) || - $this->isValidIE($value); + $this->isValidIE($value) || + $this->isValidEL($value); } + private function isValidEL( + string $value + ): bool { + if(!\preg_match('/^\d{9}$/', $value)) { + return false; + } + + if($value === '000000000') { + return false; + } + + $sum = 0; + + for($i = 0; $i < 8; $i++) { + $sum += ((int) $value[$i]) << 8 - $i; + } + + $remainder = $sum % 11 % 10; + + return $remainder === (int) $value[8]; + } + private function isValidIE( string $value ): bool { diff --git a/tests/CompanyRegistrationNumberTest.phpt b/tests/CompanyRegistrationNumberTest.phpt index a85c652..4cbdd39 100644 --- a/tests/CompanyRegistrationNumberTest.phpt +++ b/tests/CompanyRegistrationNumberTest.phpt @@ -56,6 +56,7 @@ final class CompanyRegistrationNumberTest extends TestCase '1234567T', // IE '1234567FA',// IE '2036426OA',// IE + '996861833', // EL ]; foreach ($validValues as $validValue) {