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

Is the `value()` method really necessary? #15

Closed geoffreyvanwyk closed 3 months ago

geoffreyvanwyk commented 3 months ago

The underlying string value can always be gotten with the strval function. So, no.

Is the $rawValue property really necessary? No. Just use value alone. Yes, because it is used in tests when expecting the exception messages.

This is a breaking change. The major version number of the release that includes this change should be incremented, in-keeping with semantic versioning.

geoffreyvanwyk commented 3 months ago

If I use a factory method (and a private constructory), I might get rid of the $rawValue property. Then the equality operator == should work and the the equals() will not be necessary.

geoffreyvanwyk commented 3 months ago

I got rid of $rawValue without using a private constructor. I made value() private and used it for preparing $value for validation.