reducktion / socrates

PHP package to Validate and Extract information from National Identification Numbers.
MIT License
47 stars 4 forks source link

[v2.0.0] Remove Carbon dependency #86

Closed AlexOlival closed 1 year ago

AlexOlival commented 3 years ago

As I'm working on the JS/TS/npm port, I'm striving to keep dependencies to a minimum - something that the npm ecosystem is plagued with.

However we ourselves are forcing a dependency on a DateTime wrapper library that, no matter how great it is, not all projects will use. PHP's DateTime class is fine and we should refactor our date handling to it, including Citizen's return type.

AlexOlival commented 3 years ago

An addendum: this will be a breaking change, so we're talking a major version here.

AlexOlival commented 3 years ago

Alternatively, we could deprecate the method returning the Carbon instance, and then later remove it altogether... Thoughts @JoaoFSCruz ?

JoaoFSCruz commented 3 years ago

Currently we are using Carbon when manipulating dates in the extractors and to define the date of birth in the Citizen model. If we just deprecate the Citizen's method to return a DateTime instance instead of a Carbon instance we are not making that of a difference.

Maybe really push for the bigger change and totally lose Carbon. 🤷‍♂️

AlexOlival commented 3 years ago

Maybe really push for the bigger change and totally lose Carbon. man_shrugging

It would however mean that we could have a smoother transition to getting rid of Carbon without introducing a breaking change out of the blue. Something like v1.3.0 having a new getDateOfBirthNative() method alongside the old Carbon returning one, and then on v2.0, the original getDateOfBirth() would be rewritten to return a DateTime.

JoaoFSCruz commented 3 years ago

I may have misunderstood 😅

When upgrading to a later version we can get rid of Carbon. But until then we can implement another method returning a DateTime instance for a smooth transition.

That sounds totally fine 👍