Skip to content

Commit 20b3d11

Browse files
committed
Improved phone value object validation
1 parent 3d18706 commit 20b3d11

25 files changed

+27
-24
lines changed

src/LIN3S/SharedKernel/Domain/Model/Identity/Id.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ public function equals(Id $id)
4343

4444
public function __toString()
4545
{
46-
return (string)$this->id;
46+
return (string) $this->id;
4747
}
4848
}

src/LIN3S/SharedKernel/Domain/Model/Phone/Phone.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ private function setPhone($phone)
4646
if (!$numbers) {
4747
throw new PhoneInvalidFormatException();
4848
}
49+
if (!preg_match('/^[0-9]{2,3}-? ?[0-9]{6,7}/', $numbers)) {
50+
throw new PhoneInvalidFormatException();
51+
}
4952

5053
return $numbers;
5154
}

tests/Double/Domain/Model/AggregateRootStub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
* This file is part of the Shared Kernel library.
55
*
6-
* Copyright (c) 2016 LIN3S <info@lin3s.com>
6+
* Copyright (c) 2016-2017 LIN3S <info@lin3s.com>
77
*
88
* For the full copyright and license information, please view the LICENSE
99
* file that was distributed with this source code.

tests/Double/Domain/Model/CqrsEventStub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
* This file is part of the Shared Kernel library.
55
*
6-
* Copyright (c) 2016 LIN3S <info@lin3s.com>
6+
* Copyright (c) 2016-2017 LIN3S <info@lin3s.com>
77
*
88
* For the full copyright and license information, please view the LICENSE
99
* file that was distributed with this source code.

tests/Double/Domain/Model/DomainEventStub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
* This file is part of the Shared Kernel library.
55
*
6-
* Copyright (c) 2016 LIN3S <info@lin3s.com>
6+
* Copyright (c) 2016-2017 LIN3S <info@lin3s.com>
77
*
88
* For the full copyright and license information, please view the LICENSE
99
* file that was distributed with this source code.

tests/Double/Domain/Model/EventSourcingEventStub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
* This file is part of the Shared Kernel library.
55
*
6-
* Copyright (c) 2016 LIN3S <info@lin3s.com>
6+
* Copyright (c) 2016-2017 LIN3S <info@lin3s.com>
77
*
88
* For the full copyright and license information, please view the LICENSE
99
* file that was distributed with this source code.

tests/Double/Domain/Model/Identity/IdStub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
* This file is part of the Shared Kernel library.
55
*
6-
* Copyright (c) 2016 LIN3S <info@lin3s.com>
6+
* Copyright (c) 2016-2017 LIN3S <info@lin3s.com>
77
*
88
* For the full copyright and license information, please view the LICENSE
99
* file that was distributed with this source code.

tests/Matchers/CollectionMatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
* This file is part of the Shared Kernel library.
55
*
6-
* Copyright (c) 2016 LIN3S <info@lin3s.com>
6+
* Copyright (c) 2016-2017 LIN3S <info@lin3s.com>
77
*
88
* For the full copyright and license information, please view the LICENSE
99
* file that was distributed with this source code.

tests/Matchers/DomainPublishedMatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
* This file is part of the Shared Kernel library.
55
*
6-
* Copyright (c) 2016 LIN3S <info@lin3s.com>
6+
* Copyright (c) 2016-2017 LIN3S <info@lin3s.com>
77
*
88
* For the full copyright and license information, please view the LICENSE
99
* file that was distributed with this source code.

tests/Spec/LIN3S/SharedKernel/Domain/Model/AggregateRootDoesNotExistExceptionSpec.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
* This file is part of the Shared Kernel library.
55
*
6-
* Copyright (c) 2016 LIN3S <info@lin3s.com>
6+
* Copyright (c) 2016-2017 LIN3S <info@lin3s.com>
77
*
88
* For the full copyright and license information, please view the LICENSE
99
* file that was distributed with this source code.

0 commit comments

Comments
 (0)