spatie / period

Complex period comparisons
https://spatie.be/open-source
MIT License
1.56k stars 72 forks source link

Remove double negation #47

Closed kylekatarnls closed 4 years ago

kylekatarnls commented 4 years ago

"Periods are equal if their start and end are equal" rather than: "Periods are not equal if their start or their end are not equal"

brendt commented 4 years ago

This is actually done on purpose, we find the code is easier to read for humans by splitting this big boolean expression into several steps. I appreciate the effort but we're going to keep this one.

kylekatarnls commented 4 years ago

It sounds like you took this approach in https://github.com/spatie/period/blob/2.0/src/PeriodDuration.php#L49

What is the exact rule for this code-style guideline?

brendt commented 4 years ago

Clearly there is no fixed rule 😅

To be honest, I personally don't mind the change you propose, the code was actually once written like that. It got changed after an internal review at the office because of clarity. The code you're linking to is still the WIP v2 branch, and it will probably get changed once we officially release it.

Let's ping @freekmurze because I believe he prefers the longer notation, while to me it's no bother whether it's one or the other.

I agree it should be consistent throughout the codebase, and that's not the case right now.