How to refactor complex if statements
Have you every come across confusing if statements with complex conditionals such as this? I bet you did!
// please kill me π€―
if (!(($this->shipping_country == "GB" || (strcmp($this-status, "Valid") !== 0)) {
To me, this is completely unreadable.
In the video below I show how I deal with this situation. Spoiler: add some tests around it and break the conditionals apart.
This video is part of the Mailcoach video course. It contains many more videos on how to write clear code. You can use this coupon code to get a nice discount of $10.
YES-I-WANT-TO-WRITE-READABLE-CODE