From 37a166087653a84fa8a67a64d5fb127b807eca3c Mon Sep 17 00:00:00 2001 From: Cherif BOUCHELAGHEM Date: Sat, 13 Jun 2020 11:23:24 +0100 Subject: [PATCH] Accepts other format --- spec/AlgerianMobilePhoneNumberSpec.php | 12 ++++++++++++ src/AlgerianMobilePhoneNumber.php | 1 + 2 files changed, 13 insertions(+) diff --git a/spec/AlgerianMobilePhoneNumberSpec.php b/spec/AlgerianMobilePhoneNumberSpec.php index 1754157..d1fcfc7 100644 --- a/spec/AlgerianMobilePhoneNumberSpec.php +++ b/spec/AlgerianMobilePhoneNumberSpec.php @@ -128,4 +128,16 @@ function it_is_immutable() $this->shouldNotBe($other); } + function it_accepts_space_separated_format() + { + $this->beConstructedFromString('06 99 00 00 00'); + $this->asString()->shouldReturn('0699000000'); + } + + function it_accepts_space_separated_format_with_international_indicative() + { + $this->beConstructedFromString('00213 6 99 00 00 00'); + $this->asString()->shouldReturn('00213699000000'); + } + } diff --git a/src/AlgerianMobilePhoneNumber.php b/src/AlgerianMobilePhoneNumber.php index 639fe56..96d3870 100644 --- a/src/AlgerianMobilePhoneNumber.php +++ b/src/AlgerianMobilePhoneNumber.php @@ -33,6 +33,7 @@ private function __construct(string $number) */ public static function fromString(string $number): AlgerianMobilePhoneNumber { + $number = preg_replace("/\s+/", "", $number); $algerianMobilePhoneNumber = new AlgerianMobilePhoneNumber($number); return $algerianMobilePhoneNumber; }