spoorsny / php-south-african-id

A self-validating value object encapsulating a South African government-issued personal identification number.
https://packagist.org/packages/spoorsny/south-african-id
GNU General Public License v3.0
0 stars 0 forks source link

Make `$value` constructor parameter required #13

Closed geoffreyvanwyk closed 3 months ago

geoffreyvanwyk commented 3 months ago

At the moment, the constructor parameter is optional.

See https://github.com/spoorsny/php-south-african-id/blob/master/src/ValueObjects/SouthAfricanId.php#L51

When the value object was originally developed as part of a value object, one of the tests on the class containing the value object, was for the case when the raw value passed was null. In order to get the correct type of exception (ValidationException), the constructor parameter was made optional.

At the moment, there is no test that explicitly tests what happens when passing null to the constructor. So that should be added as well.