Skip to content

Commit

Permalink
Accepts other format
Browse files Browse the repository at this point in the history
  • Loading branch information
cherifGsoul committed Jun 13, 2020
1 parent 0bb2002 commit 37a1660
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions spec/AlgerianMobilePhoneNumberSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

}
1 change: 1 addition & 0 deletions src/AlgerianMobilePhoneNumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 37a1660

Please sign in to comment.